2
我试图导入一个模块(module_name.py
),我已经创建using __import__()
但我看到下面的错误模块:导入错误尝试导入具有类方法与类型参数
Traceback (most recent call last):
File "test.py", line 80, in <module>
testImportMethod()
File "test.py", line 68, in testImportMethod
m = __import__("module_name")
File "/dir/module_name.py", line 147
def insert_model(model: MyModel):
^
SyntaxError: invalid syntax
module_name.py
具有以下代码:
class MyModel(object):
property1 = None
property2 = None
class ThingDAO(object):
@staticmethod
def get_thing_by_id(id):
...
@staticmethod
def insert_model(model: MyModel):
...
为什么导入过程对类型化参数有问题?