以下代码只是试图打印目录中所有文件的名称:
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。
我在最新版本的并行中使用 Windows 8 上的 Python 3.4。