因此,我在一个单独的文件“types.py”中定义了几个名称元组:
import collections
TestWindow = collections.namedtuple('TestWindow', 'HWND rect x y w h refPoint')
Point = collections.namedtuple('Point', 'x y')
并希望将这些类型导入另一个文件中:
from types import TestWindow, Point
def main():
pass
一旦我添加第一个导入行,我就会:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from types import TestWindow, Point
ImportError: cannot import name 'TestWindow'
这里有什么问题?