Import class form another python file Error
我有三个文件
在
1 2 3 4 | import one_file var = input("yes or no?") if var =="yes": Create() |
但我收到了这个错误。我也试过用
1 2 3 4 5 6 7 8 9 10 11 | <wyn> import random class Create: def __init__(self): self.word() def word(self): word_list = ["hello","word","sun","moon"] print("This is your word") print(random.choice(word_list)) </wyn> |
如果要从导入的库中运行代码,应首先调用导入的库。
1 2 | import one_file one_file.Create() |
否则,你可以尝试
1 2 | from one_file import Create Create() |