常用脚本之本件
2016-02-02 00:00
197 查看
#coding=utf-8 ''' Created on Nov 27 @author:tianmaxingkongdeyu ''' import os import time def nsfile(s): '''The number of new expected documents''' #判断文件夹是否存在,如果不存在则创建 b = os.path.exists("C:\\testFile\\") if b: print "File Exist!" else: os.mkdir("C:\\testFile\\") #生成文件 for i in range(1,s+1): localTime = time.strftime("%Y%m%d%H%M%S",time.localtime()) #print localtime filename = "C:\\testFile\\"+localTime+".txt" #a:以追加模式打开(必要时可以创建)append;b:表示二进制 f = open(filename,'ab') testnote = '测试文件600' f.write(testnote) f.close() #输出第几个文件和对应的文件名称 print "file"+" "+str(i)+":"+str(localTime)+".txt" time.sleep(1) print "ALL Down" time.sleep(1) if __name__ == '__main__': s = input("请输入需要生成的文件数:") nsfile(s) if __name__=="__main__": s = input("请输入需要生成的文件数:") nsfile(s)
相关文章推荐
- 常用脚本文件之批处理
- ABBYY FineReader 12完整功能列表汇总(二)
- 设置SVN忽略文件和目录(文件夹)
- how to check logcat by specify tag
- mongodb 3.0 使用mongodump、mongorestore数据迁移
- gatling简单使用说明
- CentOS 6.6 内核升级
- 企业网盘不仅只是存储
- 可视化java jvm
- Java 实现动态代理实现AOP
- 我被Java包装类教育了(Long和Integer)
- Jquery 的Ajax 注意事项
- Intellij IDE 注册流程
- 2016WC 总结
- hdu2296||UVALive 4223 Trucking (二分+spfa)
- 物联网网络编程、Web编程综述
- 列表及表格
- idea 的快捷键总结
- java 的类和接口的变量调用
- JAVA calender 的使用实现查询一个月的第1天和最后一天,学的是技巧。