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):
...
爲什麼導入過程對類型化參數有問題?