import random
import os
from PIL import Image
i = 0
while i < 5000:
r1 = random.randint(1, 9)
r2 = random.randint(11, 30)
r3 = random.randint(0,3)
year = '202'+ str(r3)
monday = '0' + str(r1) + str(r2)
filename = "D:\\" +'pic'+ year+'\\'+ monday
bh = str(random.randint(1, 1500))
bh = bh.zfill(5)
djbh = year+ monday + bh
with open('D:text.txt', 'a+') as wr: # 写入到文本中
wr.write(djbh+'\n')
djbh ="D:" +'pic'+ year+'\\'+ monday+'\\' +djbh
print(filename)
print(djbh)
if not os.path.exists(djbh):
os.makedirs(djbh)
j = 0
while j < 10:
picname = djbh + '\\'+ str(random.randint(10000, 99999))
picname2 = picname + '.jpg'
R = random.randint(0, 255)
G = random.randint(0, 255)
B = random.randint(0, 255)
img = Image.new("RGB", (1920, 1080), (R, G, B))
print(picname)
j += 1
img.save(picname2)
os.rename(picname2,picname)
print(r1,r2)
i += 1
wr.close
|