I use openpyxl for my school Excel Code is:
import openpyxl
import random
workbook = openpyxl.Workbook() #创建工作簿
worksheet = workbook.active #打开活动Sheet(0)
for row in range(1,55): #54行
for column in range(1,16): #15列
randomValue = random.choice([36.1,36.2,36.3,36.4,36.5,36.6,36.7,36.8,36.9]) #随机选择范围内数
#随机生成一个数
_ = worksheet.cell(row=row, column=column, value="{0}".format(randomValue)) #传入随机数值
#填入单元格
print(row,column,randomValue) #反馈当前进度
workbook.save("初二11班.xlsx") #保存
I am tired of that '', why use it? 为什么要用 ‘’? 它有什么作用?我无法理解
Aucun commentaire:
Enregistrer un commentaire