摘要:
import glob # path = r"E:\Python\code\*.txt" # * 匹配0个或多个字符 匹配后缀名 .txt 的文件 # path = r"E:\Python\code\z?.*" # ? 匹配 z1.py z9.py ze.py z3.num.sort.py z9.t 阅读全文
posted @ 2023-06-20 15:59
sangern
阅读(83)
评论(0)
推荐(0)
摘要:
import fileinput with fileinput.input('a.txt') as f: # , backup=".bak", inplace=1 backup inplace 同时有参数才会备份 print("*****访问一个文件 'a.txt'****") for line i 阅读全文
posted @ 2023-06-20 15:15
sangern
阅读(13)
评论(0)
推荐(0)
摘要:
fileinput模块可以对一个或多个文件中的内容进行迭代、遍历等操作,的open函数是对一个文件进行读写操作;fileinput.input()函数生成一个迭代器,遇到大文件的读取时不会占用太大的内存;fileinput对文件进行循环遍历,格式化输出,查找、替换等操作,还能获取每一行的行号等等 d 阅读全文
posted @ 2023-06-20 11:24
sangern
阅读(19)
评论(0)
推荐(0)
摘要:
def input(files=None, inplace=False, backup="", bufsize=0, mode="r", openhook=None): """Return an instance of the FileInput class, which can be iterat 阅读全文
posted @ 2023-06-20 11:01
sangern
阅读(27)
评论(0)
推荐(0)

浙公网安备 33010602011771号