随机生成一大堆特定文件名的文件
测试文件检索用的
import os, random, string
year_all = ['2010', '2011', '2012', '2013', '2014']
month_all = range(1, 13)
day_all = range(1, 32)
location = '/home/plum/Develop/redleaf/data/'
def name_pick(time):
name = ''
for i in range(time):
name = name + random.choice(string.ascii_letters)
return name
def random_thing(list):
d = str(random.choice(list))
if len(d) < 2:
d = '0' + d
return d
for i in range(2000):
filename = random.choice(year_all) + random_thing(month_all) + random_thing(day_all) + '-' + name_pick(10) + '.pdf'
finalcmd = 'touch {a}{b}'.format(a=location, b=filename)
os.popen(finalcmd)
print ('{cmd}运行正常'.format(cmd=finalcmd))
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »