【发布时间】:2016-01-18 23:57:04
【问题描述】:
以下代码只是试图打印目录中所有文件的名称:
from pathlib import Path
for myPath in Path.cwd().iterdir():
print (myPath.name())
它给了我错误:
Traceback (most recent call last):
File "NameTest.py", line 4, in <module>
print (myPath.name())
TypeError: 'str' is not callable
如果我打印“myPath”对象类型,目录中的所有内容都会返回类 pathlib.windowspath。
我在最新版本的 parallels 中在 Windows 8 上使用 Python 3.4。
【问题讨论】:
标签: python path typeerror python-3.4