如何快速不用库地读取txt里面的内容,不考虑时间复杂度

如何快速不用库地读取txt里面的内容,不考虑时间复杂度

巧了啊巧了啊,我正好写过这个程序

def removeN():
    asd = " "
    c = ""
    bd = []
    de = 0
    fg = "\n"
    with open('data.txt','r') as usrFile:
        asd = usrFile.readlines()
        for j in range(len(asd)):
            er = asd[j]
            pos = er.index(fg)
            cex = er[0:pos]
            bd.append(cex)
            de = 0
            cex = ""
        return bd

用这个函数就好。
不过我建议你还是去学一学pandas好一点