reading from a txt file

Jason Friedman jsf80238 at gmail.com
Thu Nov 26 16:04:34 EST 2015


>
> Hey, I'm wondering how to read individual strings in a text file.  I can
> read a text file by lines with .readlines() ,
> but I need to read specifically by strings, not including spaces.  Thanks
> in advance
>

How about:

for a_string in open("/path/to/file").read().split():
    print(a_string)



More information about the Python-list mailing list