文件管理-Python


# f = open(r'D:\day03\笔记', 'r', encoding='utf-8')
# print(f.read())
# f.close()


# 读写图片
# # 读取二进制数据
# with open(r'D:\day03\妹子图.jpg', 'rb') as f:
# res = f.read()
# print(res)
#
#
# # 将读取出来的图片数据,写入一个新的文件中, 该文件后缀也必须是 .jpg
# with open(r'D:\day03\meizitu.jpg', 'wb') as f:
# f.write(res)


# 读写视频
# 读取二进制数据
# with open(r'D:\day03\昨日回顾.mp4', 'rb') as f:
# res = f.read()


# 将读取出来的图片数据,写入一个新的文件中, 该文件后缀也必须是 .jpg
# with open(r'D:\day03\new_video.mp4', 'wb') as f:
# f.write(res)


# 读取大文件需要 一点一点读取
# with open(r'D:\day03\0 昨日回顾.mp4', 'rb') as f:
# number = 1
# for line in f: # f也是一个可迭代对象
# print('=' * 100)
# print(line, number)
# number += 1

posted @ 2020-01-15 16:28  lianbingrong  阅读(145)  评论(0编辑  收藏  举报