Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在windows中打开磁盘并在低级别读取数据?_Python_Windows_Disk_Low Level - Fatal编程技术网

Python 如何在windows中打开磁盘并在低级别读取数据?

Python 如何在windows中打开磁盘并在低级别读取数据?,python,windows,disk,low-level,Python,Windows,Disk,Low Level,我知道在linux中,它和/dev/sda一样简单,但在Windows中,如何打开磁盘并开始在低级别读取数据 在python中,我尝试过: f = open("K:", "r") 我得到了这个错误: Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 13] Permission denied: 'K:' 回溯(最近一次呼叫最后一次): 文件“

我知道在linux中,它和/dev/sda一样简单,但在Windows中,如何打开磁盘并开始在低级别读取数据

在python中,我尝试过:

f = open("K:", "r")
我得到了这个错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'K:'
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
IOError:[Errno 13]权限被拒绝:“K:”
即使作为管理员,我也会收到此错误。

来自

为打开物理硬盘驱动器 磁盘中的直接磁盘访问(原始I/O) 基于Win32的应用程序,使用设备 表格名称

其中N是0、1、2等等, 代表每一个物理层 系统中的驱动器

要打开逻辑驱动器,请直接访问 是那种形式的

其中X:是a 硬盘驱动器分区号,软盘 磁盘驱动器或CD-ROM驱动器


请记住,windows和其他操作系统中的所有对象都是文件。要从驱动器E打开并读取16字节的数据:请使用以下代码:

# Open a Disk in binary format read only 16 bytes
file = "\\\\.\\E:"
with open(file,'rb') as f:
    print("Disk Open")
    data = f.read(16)
    # Convert the binary data to upper case hex ascii code
    hex_data = " ".join("{:02X}".format(c) for c in data)
    print(hex_data)

我想我必须使用win32扩展名win32文件?有人知道吗?你怎么知道哪个驱动器是哪个驱动器?我猜disk manager是正确的,但在做任何破坏性的事情之前,我会仔细检查:-)使用python执行此操作:
CreateFile
的其他参数是什么?
\\.\X: 
# Open a Disk in binary format read only 16 bytes
file = "\\\\.\\E:"
with open(file,'rb') as f:
    print("Disk Open")
    data = f.read(16)
    # Convert the binary data to upper case hex ascii code
    hex_data = " ".join("{:02X}".format(c) for c in data)
    print(hex_data)