This commit is contained in:
2025-08-26 17:30:04 +08:00
parent e58a4612ef
commit b411789fd3
12 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import csv
# 写入 CSV
with open('data.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['Name', 'year', 'value']) # 写入表头
writer.writerow(['Guan', 1993, 1])
writer.writerow(['G123', 2025, 0])
# 读取 CSV
with open('data.csv', 'r', encoding='utf-8') as f:
reader = csv.reader(f)
for row in reader:
print(row) # 每行是一个列表