Python读写文本

2018-05-02  本文已影响0人  一川烟草_满城风絮_梅子黄时雨
helloFile = open('./hello')
helloContent = helloFile.read()
print(helloContent)
lines = helloFile.readlines()
print(lines)
for line in helloFile:
    print(line)
with open('io.py') as f:
    for line in f:
        line = line.strip()
        print(line)
tmpFile = open('bacon.txt', 'w')
tmpFile.write("hello world!\n")
helloFile.close()
上一篇 下一篇

猜你喜欢

热点阅读