hi, there is error when running the code: > Traceback (most recent call last): > File "C:/Python25/myscript/log/readfile9.py", line 5, in <module> > port, channel, lane, eyvt = line.split() > ValueError: need more than 2 values to unpack
the error is due to below line code: >port, channel, lane, eyvt = line.split() pls advise. thanks tcl76 > Date: Sun, 9 Jan 2011 17:44:58 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Open a text file, read and print pattern matching > > Please excuse the double post, I had a problem with my email program. > > tee chwee liong wrote: > > hi, > > > > i have a sampledata as below. Pls refer to output, if found -1, how to list > > out all the Lane number? And if there is no -1, print PASS. My code is as > > below section. > > > ####Code#################### > > fname = "sampledata.txt" > > pattern = "-1" > > for search in open(fname): > > if pattern in search: > > print "FAIL" > > else: > > print "PASS" > > fname = "sampledata.txt" > pattern = "-1" > failed = False > for line in open(fname): > port, channel, lane, eyvt = line.split() > if int(eyvt) == -1: > failed = True > print "Lane %s failed." % lane > if not failed: > print "All lanes pass." > > > -- > Steven > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor