我想从磁盘E:或我的SD卡中读取所有字节,我的代码是:
with open("E:", "rb") as byteData:
try:
byteData.seek(self.offset.value() * 512, os.SEEK_SET)
print(self.offset.value() * 512)
block = byteData.read(BLOCK_SIZE)
except ValueError: # Empty offsetSpinbox
return我得到了这个错误:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
with open("E:", "rb") as byteData:
PermissionError: [Errno 13] Permission denied: 'E:'发布于 2021-01-18 12:06:32
您可以尝试以管理员身份从cmd.exe运行,甚至可以创建一个快捷方式来使用所有权限执行脚本
发布于 2021-01-18 20:52:22
要从驱动器E:访问原始字节,可以考虑使用\\.\E:。请注意,读取原始字节需要对齐。
# The backslashes need to be escaped.
with open("\\\\.\\E:", "rb") as byteData:
try:
byteData.seek(self.offset.value() * 512, os.SEEK_SET)
print(self.offset.value() * 512)
block = byteData.read(BLOCK_SIZE)
except ValueError: # Empty offsetSpinbox
return您还可以使用\\.\physicaldrive0直接从物理磁盘读取数据,其中0可以是磁盘的索引。
附注:以上操作需要管理员权限。
https://stackoverflow.com/questions/65768609
复制相似问题