If someone could aid me in finding my flaw, what I want the script to do is every minute a different random number is appended to the rows. The result I am getting just gives me the same number down the rows.
from openpyxl import Workbook
from openpyxl import load_workbook
import random
import schedule
import time
import datetime
def create_excel(info, info2):
wb = Workbook()
ws = wb.active
n = 1
ws.title = 'Test ' + str(n)
ws['A1'] = 42
wb.save('sample.xlsx')
while n < 4:
wb = load_workbook('sample.xlsx')
ws = wb.active
ws.append([info, info2])
n += 1
wb.save('sample.xlsx')
def main():
print('Starting program now....')
int = random.randint(55, 99)
int2 = random.randint(1, 50)
excel(int, int2)
print('Finished program.')
m = 1
schedule.every(1).minute.do(main)
while m < 4:
schedule.run_pending()
time.sleep(60)
m += 1
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…