Python模块'os'没有属性'mknod' [英] Python module 'os' has no attribute 'mknod'
问题描述
我想使用mknod
命令在Python中创建一个新文件,但出现错误:
os.mknod();
AttributeError: module 'os' has no attribute 'mknod'
我正在使用Windows,并且'mknod'
以外的属性都在起作用.
os
提供与您所使用的操作系统密切相关的功能.如果可以从os
访问大多数其他属性(这意味着当前目录中没有os.py
文件掩盖了标准模块),则AttributeError
将99%表示您的操作系统不支持该功能. >
在Windows上使用os.mknod
就是这种情况.据我了解,在Windows
中创建命名管道具有非常不同的语义
无论哪种方式,如果您尝试使用mknod
创建命名管道,则最好使用 mkfifo()
(同样,仅支持Unix
).如果要使用它创建普通文件,请不要使用可移植的open()
.
I want to create a new file in Python for that I am using mknod
command, but getting error as:
os.mknod();
AttributeError: module 'os' has no attribute 'mknod'
I am using windows and attributes other than 'mknod'
are working.
os
offers functionality that is closely related to the OS you're using. If most other attributes can be accessed from os
(meaning you haven't got a os.py
file in the current dir masking the standard module) an AttributeError
will 99% signal an unsupported function on your Operating System.
This is what the case is with os.mknod
on Windows. Creating named pipes in Windows
has, as far as I can understand, very different semantics.
Either way, if you are trying to use mknod
to create named pipes you'd probably be better using mkfifo()
(again, only Unix
supported) . If you're using it to create ordinary files, don't, use open()
which is portable.
这篇关于Python模块'os'没有属性'mknod'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!