小编Hal*_*ard的帖子

"OSError:[Errno 22]无效参数"读取()大文件时

我正在尝试编写一个打印文件校验和的小脚本(使用https://gist.github.com/Zireael-N/ed36997fd1a967d78cb2中的一些代码):

import sys
import os
import hashlib

file = '/Users/Me/Downloads/2017-11-29-raspbian-stretch.img'

with open(file, 'rb') as f:
    contents = f.read()
    print('SHA256 of file is %s' % hashlib.sha256(contents).hexdigest())
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误消息:

Traceback (most recent call last):
  File "checksum.py", line 8, in <module>
    contents = f.read()
OSError: [Errno 22] Invalid argument
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我在macOS High Sierra上使用python 3

python macos file-io python-3.x

13
推荐指数
1
解决办法
7836
查看次数

标签 统计

file-io ×1

macos ×1

python ×1

python-3.x ×1