CSV Simple example of file data writing
import csv
# Example , In the same category Automatically create my.csv file , Write data
with open('my.csv', "a", newline='') as f:
writer = csv.writer(f)
writer.writerow(["URL", "predict", "score"])
row = [['1', 1, 1], ['2', 2, 2], ['3', 3, 3]]
for r in row:
writer.writerow(r)
# Custom path , Write data
ave_per = 32.658
delta_path = r'C:\Users\weiwei\Desktop\my.csv'
delta = format(ave_per - 31.667, '.3f')
with open(delta_path, "a", newline='') as f:
writer = csv.writer(f)
writer.writerow([delta])