I have a very simple python script that should scan a text file, which contains lines formatted as id='value' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:
import os,sys
from os import *
from sys import *
vals = {}
f = open(sys.argv[1], 'r')
for line in val_f:
t = line.split('=')
t[1].strip(''')
vals.append(t[0], t[1])
print vals
f.close()
when i try to run it i get:
Traceback (most recent call last):
File "chval.py", line 9, in ?
f = open(sys.argv[1], 'r') TypeError: an integer is required
I'm using python 2.4... because i've been challenged to not use anything newer, is there something about open() that I don't know about? Why does it want an integer?
anything after that line is untested. in short: why is it giving me the error and how do i fix it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…