简体   繁体   中英

Read from a *.txt file lines with 10, 20 even 30 hashtags ("#######...)

I know there are examples on how to extract hashtags from strings. What I am interested is to read a text file line by line , even if it has some lines with hashtags not one but a bunch ie "######## line information ######".

f = open('file.txt')
line = f.readline()
while line:
    line = line.replace('#', '')
    print(line)
    line = f.readline()
f.close()

Let me know if you need anything else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM