KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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?
Tags (comma-separated)
Save Edits
Cancel