Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.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 属性错误:模块';操作系统&x27;没有属性';uname_Python_Operating System - Fatal编程技术网

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'