python - 如何用python调用 'read'系统调用

标签 python linux python-2.7 system-calls fuse

我需要使用我的参数运行 linux 'read' 系统调用。有什么想法吗?

read(const char *path, char *buf, size_t size, off_t offset,struct fuse_file_info *fi)

我需要用我的参数调用上面的函数。

最佳答案

Python 公开 the C stdlib read() function作为os.read() function :

os.read(fd, n)
Read at most n bytes from file descriptor fd. Return a string containing the bytes read. If the end of the file referred to by fd has been reached, an empty string is returned.

错误作为 OSError 异常引发,errno 属性设置为整数,如 C read() 文档中所述。您可以使用 errno module如果您想要测试常量。

关于python - 如何用python调用 'read'系统调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24513946/

相关文章:

python - 如何避免在 PyTest 中从 session 范围固定装置中改变对象?

python - {{ user.get_profile.foo }} 在 Django 中不起作用

python - 我没有 Nvidia GPU,但想在 CPU 上运行 Tensorflow 模型。为什么它一直要求一些 CUDA DLL?

JSON 结合保持文件夹结构的 gulp 任务 - 跨平台

linux - 阻止构建管道的 Teamcity 构建代理

python - 更改范围函数内的步长值?

python - 同时使用 urllib2.urlopen() 进行多个请求

linux - 如何将文件从远程机器传输到我的电脑

python - 如何在 Python 2.7 中使用带参数的 super()?

python-2.7 - 尝试通过 p12 访问 Google Directory API 引发未授权错误