Python 属性错误:模块';操作系统&x27;没有属性';uname
当我这样做时:Python 属性错误:模块';操作系统&x27;没有属性';uname,python,operating-system,Python,Operating System,当我这样做时: >>> import os >>> os.uname() 我得到一个属性错误,如下所示: Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> os.uname() AttributeError: module 'os' has no attribute 'uname' 回溯(最近一次呼叫最后一次): 文件“”
>>> import os
>>> os.uname()
我得到一个属性错误,如下所示:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.uname()
AttributeError: module 'os' has no attribute 'uname'
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
os.uname()
AttributeError:模块“os”没有属性“uname”
我如何修复这是因为我的python坏了还是其他原因,因为在。感谢您的高级支持。我在Windows 10上以完全相同的方式在空闲状态下运行了您的代码,并得到了相同的结果
>>> print(os.uname())
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
print(os.uname())
AttributeError: module 'os' has no attribute 'uname'
如果您想获得当前的操作系统,我建议使用平台
模块
>>> import platform
>>> platform.platform()
'Windows-10-10.0.18362-SP0'
有些人更喜欢使用
os
模块,但平台
可读性更强。可用性:Unix的最新版本。
正如前面所指出的,并非所有操作系统都可以使用它。你想获得什么信息?
>>> import platform
>>> platform.platform()
'Windows-10-10.0.18362-SP0'