python 数据类型---文件二

1.打印进度条

import sys,time
for i in range(20):
sys.stdout.write("#")
sys.stdout.flush() #不等缓冲区满就打印输出
time.sleep(0.1)

2. "r+", "w+", "a+" ,"rb"  读写模式, 写读模式, 追加读写模式, 二进制读写模式(一般用于网络传输)

3. with 用法

Sytanx  ''' with open("file1.txt") as obj1, open("file2.txt") as ojb2:  '''

with 用于避免忘记关闭文件而生

with open("lyric.txt", "r", encoding="utf-8") as f,\
open("lyric_2.txt", "r", encoding="utf-8") as f2:
for line in f:
print(line)
上一篇:poj 2431 Expedition 贪心+优先队列 很好很好的一道题!!!


下一篇:POJ 2431 Expedition(优先队列、贪心)