我想用一个循环创建10个目录,我尝试了以下代码:
import os
pathname = 1
directory = "C:\Directory\Path\Name\\" + str(pathname)
while pathname < 11:
if not os.path.exists(directory):
os.makedirs(directory)
pathname += 1
但它只是创建了第一个目录,然后停止了,好像它根本就没有经历过其他的循环一样,我对python还相当陌生,这段代码对我来说很有意义,我不知道为什么它可能不这样做工作。任何感谢帮助。在
相关问题 更多 >
编程相关推荐