我有两个文件,我想从另一个文件中导入一个类。如何从其他.py文件中调用一个.py文件中存在的函数?
文件one.py
:
class One:
def printNumber(self, a):
print (a)
和文件two.py
:
#import One # gives error no module named One
#import one # gives error no module named one
class Two:
# Here I want to call printNumber method from one.py
您是否尝试过谷歌搜索, “如何在Python进口”? – NonCreature0714
如果这是python 2,根据它的语法来判断,你可能需要在同一个目录中有一个名为'__init__.py'的文件(无法获得下划线语法....) – user3684792
[Python导入力学](http://stackoverflow.com/questions/1917958/python-import-mechanics) – Prune