python - Windows "nul"文件上的 os.stat

标签 python windows dev-null

为什么我不能在特殊的 Windows 文件 nul 上调用 os.stat

>>> import os
>>> os.stat('nul')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 87] The parameter is incorrect: 'nul'

我可以打开它:

>>> f = open('nul', 'r')
>>> f.read(10)
''

我希望通过 stat.S_ISCHR 和惊讶地发现我无法统计我可以打开的文件。

最佳答案

根据这个旧的 Python 错误,它应该是这样的:

http://bugs.python.org/issue1311

关于python - Windows "nul"文件上的 os.stat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13715101/

相关文章:

python - 将文件传递给 docker 命令

python - 使用 imagemagick 和 python 合成多组图像时线程延迟

windows - 远程桌面端点 Windows Azure 云 微软

bash ->/dev/null 如何消耗输出流?

c -/dev/null 总是可以打开的吗?

python - 使用 python 响应 JS 服务器端渲染

python - wxPython : Problem updating background color of controls

PHP exec 或 shell_exec 未在 Windows Wamp 上返回进程 ID (PID)

c++ - 适用于 C++、Windows 的 Torrent 库

fortran - 写入/dev/null 时记录结束