Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 python 打印目录中的所有文件名?为什么这不起作用?
for file in glob.glob("*"): print(file)
那应该行得通。我认为您只是缺少导入。尝试:
import glob for file in glob.glob("*"): print(file)