0
Searching words in a specific field inside a file using readline
I would like to created a list with the first five fields and another 6 fields starting at the 20th collun of each line of a text file. Can I use this code or maybe there is another easier way? For line in file: Line = readline() Field1=line[:6] Field2=line[20:27]
2 odpowiedzi
+ 4
You forgot to open file. Without it, it won't work.
And python is case-sensitive language.
So, "line" and "Line" are two different variables....
This code will give you exception (error)..
0
Yes thanks. But is there another pythonic idea to create the variables Field1 and Field2 ?