无法打开文件“ import.py”:[Errno 2]没有这样的文件或目录

时间:2020-10-10 23:58:36

标签: python

下面是我的代码,这就是为什么我不知道他们的问题所在,有人可以帮助我吗

这是错误消息

python3:无法打开文件'import.py':[错误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"]
        )

1 个答案:

答案 0 :(得分:0)

  1. 您需要先进入程序的目录
  2. 以“ python”开头,然后是程序名称

您可能会在下面的图片中看到我的程序

Click here to see

我希望您觉得它有用

相关问题