我正在尝试编写一个打印文件校验和的小脚本(使用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