- #! /usr/bin/env python
- # -*- coding:utf-8 -*-
- import os
- def text_creation():
- path = 'd://a//'
- for name in range (1,11):
- with open(path + str(name) + '.txt','w') as text: #写文件
- text.write(str(name))
- text.close()
- print ('创建'+ str(name) + '.txt 成功')
- text_creation()
来源: http://www.bubuko.com/infodetail-2647690.html