我正在尝试将数据写入文件。以下是我如何进行。
values = [45, 67, 39]
with open(os.path.join(path_class, r'first_file.csv'), 'a') as f:
writer = csv.writer(f)
writer.writerow(values)
但我想在 first_file.csv 位置有一个变量。
我的问题在这里with open(os.path.join(path_class, r'file_name.csv')
所以我想要类似的东西:
list_of_file = ['first_file.csv', 'second_file.csv']
for i in range(0, len(list_of_file):
with open(os.path.join(path_class, r+list_of_file[i]), 'a') as f:
writer = csv.writer(f)
writer.writerow(values)
我该怎么做
谢谢您花时间回答我的问题。
拉丁的传说
青春有我
相关分类