# Assuming your csv file is named 'file.csv' and is in the same directory that this code is running
with open ("formatted_file.csv", "w") as formatted_file:
with open ("file.csv", "r") as file:
for line in file:
formatted_line = line.rstrip()[1:-1] + "\n"
formatted_file.write(formatted_line)
然后使用新创建的文件。要检查它是否正常,您可以阅读以下内容:
with open ("formatted_file.csv", "r") as formatted_file:
for line in formatted_file:
print(line, end='')
2条答案
按热度按时间xmd2e60i1#
你可以试试这个:
输出:
iq0todco2#
首先重新格式化文件:使用下面的代码删除开始双引号、结束换行符和结束双引号:
然后使用新创建的文件。要检查它是否正常,您可以阅读以下内容: