文件读取



# open 参数介绍
# file 用来指定打开的文件的路径
# mode 用来指定打开文件的 模式

###
#   r 只读模式 只能读取 不能写入 文件不存在会报错
#   w 写入模式 只能写入 不能读取
#   b 以二进制形式 打开文件
#   rb  以二进制读取  
#   rb  以二进制写入
#   a  追加模式 文件不存在 会创建文件
#
# ###

# encoding 用来指定编码方式
 
# file = open('1.txt',encoding='utf8' )
# print(file.read())

# 只去取一行数据
# print(file.readline())


# while True:
#     content = file.readline()
#     if content == '':
#         break  
#     print(content)


# 读取所有的数据  保存到一个列表里
# x = file.readlines()
# print(x)

# 读取长度
# x = file.read(10)
# print(x)


file = open('1.mp4','rb')
# print(file.read())

while True:
    content = file.read(1024)
    if not content:
        break
    print(content)

 
# 关闭文件
file.close()
posted @ 2025-01-02 16:28  13522679763-任国强  阅读(6)  评论(0)    收藏  举报