

实例如下所示:
#coding=utf-8
'''
Created on 2012-5-29
@author: xiaochou
'''
import os
import time
def nsfile(s):
'''The number of new expected documents'''
#判断文件夹是否存在,如果不存在则创建
b = os.path.exists("E:\testFile\")
if b:
print("File Exist!")
else:
os.mkdir("E:\testFile\")
#生成文件
for i in range(1,s+1):
localTime = time.strftime("%Y%m%d%H%M%S",time.localtime())
#print localtime
filename = "E:\testFile\"+localTime+".java"
#a:以追加模式打开(必要时可以创建)append;b:表示二进制
f = open(filename,'ab')
testnote = 'private String username'
f.write(testnote.encode('utf-8'))
f.close()
#本想利用Python 读取excel 文件,对应生成domain 文件,但是由于时间关系,暂时先不开发了,这里先生成.java 文件,未来有时间进行开发,也算给编程,代码搬运工减少工作量。
