记录#
- 今天没有知识点学习,只有编码练习。
- 编写一个超级综合的程序,在本地读取写入音乐信息。
- 今天的编程大体还算顺利,只是记错了 csv.DictReader 和 csv.Reader。只有 DictReader 读取之后才是字典形式。
CODE#
import csv, os
print("artist")
with open("100MostStreamedSongs.csv", "r") as file:
reader = csv.DictReader(file)
folder = os.listdir()
for row in reader:
if row['Artist(s)'] not in folder:
os.mkdir(row['Artist(s)'])
pathname = f"{row['Artist(s)']}/{row['Song']}.txt"
with open(pathname, "w") as f:
f.write(pathname)
print("done!")