0

I'm trying to learn sys.argv and taking arguments from the command line. But when I try to open my file, it says:

"IOError: [Errno 2] No such file or directory: 'inputfile.txt'"

Here's my code:

import sys, re, 


file1 = open(sys.argv[1], "r")
file1 = file1.read()

print(file1)

Here's what I'm putting in terminal:

python /Users/vincentdang/Desktop/Assignment1/hey.py inputfile.txt

can anyone give me some tips?

sacuL
  • 42,057
  • 8
  • 58
  • 83
Vince
  • 1

0 Answers0