简体   繁体   中英

can't open file 'import.py' :[Errno 2] No such file or directory

Down below is my code my why i don't know their is a problem in it can someone help me out

THIS IS THE ERROR MESSAGE

python3: can't open file 'import.py': [Errno 2] No such file or directory

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. You need to go to your program's directory first
  2. start with "python" and followed by your program's name

You may see my program in the pic below

点击这里查看

I hope you find it usefull

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM