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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -