Python Read/Write Text File

python day 34

Plain text files are broadly used in Data Science nowadays. For example, in NLP, Natural Language Process, we usually import plain text files for sentimental analysis. Such as movie review, “good”, “bad”…

So today we will learn how to read text files in Python.

Example: No Feeling, yibo wang

text file edit website: https://www.editpad.org/

def r_text():

    text=open(r"C:/Users/ya/Desktop/no_feeling.txt", encoding='utf-8')
    print(text.read())
    text.close()

    # read files like line
    #with open(r"C:/Users/ya/Desktop/no_feeling.txt",encoding='utf-8') as f:
    #    lines = f.readlines()
    #print(lines)
r_text()
No Feeling - yibo wang

被表扬被喜欢当然值得期待
得到很多以后 你说不爱又离开
别做任别人操控情绪的木偶
对负面评价保持无感 不理不睬
破碎的刺痛的
被攻击被嘲笑挑衅
无感是将伤害最好的回击
无感赐我勇敢的心不畏惧 Yeah
没有事情过不去天塌了还有爱在
只有过不去的情绪才会把你紧紧的绑起来
太阳下山了夜里也有灯打开
你看这世界不坏
我没有你想象的好
也没有他想象的坏
只看到部分的我就很喜欢
把我惯坏 又来狠狠一踩
爱是一瞬间的情感
舞台的灯不就开了又关
每天都有人在上下台
就保持无感
Woo~
Woo~
就保持无感
不计较成败
Woo~
Woo~
就保持无感
才有幸福感
你是流量超红ppt上全部都是你
你红的没作品骂你的声音更变本加厉
I’m running running running in a circle
困住的自己不能把目标变清晰
如何前行
丢掉过去
爱我的人才不会痛 Love wakes me
逆境之路看到未来
摔倒以后站得起来
如果每天活的左顾右盼
还能谈什么生命的精彩
逆境之路看到未来
摔倒以后站得起来
不要轻易被情绪打败
就保持无感
Woo~
Woo~
就保持无感
不计较成败
Woo~
Woo~
就保持无感
才有幸福感
Tell me where you at now
Tell me where you at now
Finding the way
Follow the light that you see
Finding the way
Follow the light that you see
自由自在

happy studying!

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: