Unable to read in files in Python 2.7.4 with open(sys.argv[]) -
i within python environment in terminal on mac (os lion).
the python script contains following lines,
def main(): file1 = open(sys.argv[1]) file2 = open(sys.argv[2]) file3 = open(sys.argv[3])
i assume that need run script doing:
script.py file1.txt file2.txt file3.txt
but keep getting error message below:
>>> process.py output1.txt output2.txt output3.txt file "<stdin>", line 1 process.py output1.txt output2.txt output3.txt ^ syntaxerror: invalid syntax
all files , script in current working directory (i checked import os
, , run print os.getcwd()
. can point me right direction? thanks!
you cannot run python scripts within python itself.
you need start script command line:
python script.py file1.txt file2.txt file3.txt
Comments
Post a Comment