Im making a simple file read program to read a file via the command line using arguments. Im trying to implement an if-statement saying that if the arguments are nog equal to 2 arguments give an error, but it gives me an syntax error at my if-statement. Anyone knows what the problem is ?
I have tried running it without it the if-statement. It works that way so that isnt the problem i guess.
import sys
script = sys.argv[0]
filename = sys.argv[1]
print(f"This is your file: {filename}")
txt = open(filename)
print(txt.read())
if len(sys.argv) =! 2:
sys.stderr.write("E: Usage is <filename.txt>")
Aucun commentaire:
Enregistrer un commentaire