【发布时间】:2016-12-21 21:55:27
【问题描述】:
我有两个文件,我想从另一个文件中导入一个类。
文件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 中导入”?
-
如果这是python 2,根据语法判断,您可能需要在同一目录中有一个名为'init.py'的文件(无法获取下划线语法....)
标签: python python-3.x import