下面是我的代码,为什么我不知道他们有问题,有人可以帮助我吗
这是错误消息
python3:无法打开文件“import.py”:[Errno 2]没有这样的文件或目录
from cs50 import SQL
from sys import argv
import csv
# checking if code is executed properly else exit
if len(argv) < 2:
print("usage error, import.py characters.csv")
exit(1)
# Open the database for later reuse
db = SQL("sqlite:///students.db")
def division_title(initial):
n = initial.split()
if len(n) == 3:
return n
else:
[n[0],None,n[1]]
with open(argv[1]) as csvfile:
for row in csv.DictReader(csvfile):
n = division_title(row["name"])
db.execute("INSERT INTO student VALUES (?, ?, ?, ?, ?)",
n[0],n[1],n[2],row["house"],row["birth"]
)
牧羊人nacy
相关分类