python 循环读取大文件内容举例

with open('123.txt', 'r') as f:
    while True:
        str = f.read(1024)    # 每次读取1024字节
        if not str:
            break
        print(str, end='')     # 设置print不自动添加换行符

猜你喜欢

转载自blog.csdn.net/ljz0929/article/details/119685349