1
此問題被標記爲duplicate。但duplicate問題涉及模塊,而我的問題是要求如何導入模塊的部分。僅導入模塊的某些部分,但將這些部分列爲字符串
我知道我可以使用from mymodule import myfunction
模塊的某些部分import
。如果要導入幾件事情,但我需要將它們列爲字符串。例如:
import_things = ['thing1', 'thing2', 'thing2']
from mymodule import import_things
我沒問this question,但它看起來像我需要使用的伎倆(如果有的話)以上爲我的代碼。
任何幫助表示讚賞。
這個從包中導入模塊。我需要能夠從模塊導入方法和類。 – flashburn
@flashburn更新了我的答案 – smac89
另一個問題。我將如何取消導入它們?有沒有辦法做到這一點? – flashburn