text=f.read()
To read a file’s contents, call
f.read(size)
, which reads some quantity of
data and
returns it as a string.
size is an optional numeric argument. When
size is omitted or negative, the entire contents of the file will be read and
returned; it’s your problem if the file is twice as large as your machine’s
memory. Otherwise, at most
size bytes are read and returned. If the end of
the file has been reached,
f.read()
will return an empty string (
""
).
so you get a string in text var. Then, for against this string isn't productive.
If you wish read file line by line simply use this contruction
f = open(filename, 'rU')
rez = {}
for line in f:
пятница, 22 декабря 2017 г., 8:53:28 UTC+3 пользователь san jeev написал: