作者:机加工N_918 | 来源:互联网 | 2024-11-11 08:14
随机生成千万数据代码"""功能:生成大量数据时间:2019.4.22"""import randomfilepath = 'C:/Users/Administrator/Desktop/shy.txt
随机生成千万数据代码
"""
功能:生成大量数据
时间:2019.4.22
"""
import random
filepath = 'C:/Users/Administrator/Desktop/shy.txt'
shuju = ['a','b','c','d','e','f','g','h','i','j','k']
schools = ['计算机科学学院' , '机械工程学院' , '信息与通信工程学院' , '机械工程学院']
num = range(10000000,20000000)
aa = "姓名 学号 成绩 院系"
with open(filepath , 'a' ) as f:
f.write(aa + '\n')
for i in num :
name = ''
for j in range(0,5):
name += random.choice(shuju)
sname = name.title()
snum = str(i)
sgread = str(random.randint(0,100))
sschool = random.choice(schools)
massage = sname +4* ' ' + snum +4* ' ' + sgread +5* ' ' + sschool
with open(filepath , 'a' ) as f:
f.write(massage + '\n')
f.close()