Jia Junping's "Statistics" (7th edition) notes and answers to after-school exercises

Link: https://pan.baidu.com/s/1Vzzfujg0VwyvvLoauv8Gtw

Extraction code: znv8


import csv

def write_csv_file(rows = [], user_file_name = 'index'):
    with open(user_file_name + '.csv', 'w', newline='') as csv_file:
        writer = csv.writer(csv_file)
        writer.writerows(rows)
    print('Writing to ' + user_file_name + '.csv'+ ' has compeleted')


if __name__ == "__main__":
  rows = ['Item','name','quantity']
	user_parameter['file_name'] = 'text'
	write_csv_file(rows, user_parameter['file_name'])

The above is the python code to write .csv,

Guess you like

Origin blog.csdn.net/m0_48400495/article/details/107109223