python 数据类型---文件二

it2022-05-05  157

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)

 

转载于:https://www.cnblogs.com/frankb/p/6204571.html


最新回复(0)