问Python如何在桌面创建10个数字命名的文件?

答 1 个回答|206 次阅读
Coco老师 - 官方公众号:青少儿编程学习网
擅长:编程教育网站:https://kidscodes.cn/
def text_creation():    
path = 'C:/Users/Administrator/Desktop'    
for name in range (1,11):        
    with open(path + str(name) + '.txt','w') as text:                
       text.write(str(name))                
       text.close()            
print ('done')text_creation()

推荐课程 »更多

    推荐知识

    Python精选库大全,青少年Python编程学习总结

    Python最适合青少儿进阶学习的编程语言