AttributeError: module #39;os#39; has no attribute #39;uname(AttributeError:模块“os没有属性“uname)
问题描述
当我这样做时:
>>> import os
>>> os.uname()
我收到如下所示的属性错误:
I get an attribute error which looks like this:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.uname()
AttributeError: module 'os' has no attribute 'uname'
我该如何解决这是我的 python 损坏或其他问题,因为在 文档.提前谢谢你.
How can I fix this is my python broken or something else because in the docs. Thank you in advanced.
推荐答案
我在 Windows 10 上的 IDLE 中以完全相同的方式运行您的代码,并得到了相同的结果.
I've run your code the exact same way in IDLE on Windows 10 and got the same result.
>>> 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'
正如@Joran Beasley 指出的那样,此功能仅在 中可用某些操作系统.
And as @Joran Beasley pointed out, this function is only available in certain operating systems.
来自在线编译器:
posix.uname_result(sysname='Linux', nodename='Check', release='5.4.10-x86_64-linode132', version='#1 SMP PREEMPT Thu Jan 9 21:17:12 UTC 2020', machine='x86_64')
如果你想获取当前的操作系统,我推荐 platform 模块.
If you want to get current os, I recommend the platform module.
>>> import platform
>>> platform.platform()
'Windows-10-10.0.18362-SP0'
有些人更喜欢使用 os 模块,但 platform 更易读.
Some people prefer using os module, but platform is much more readable.
这篇关于AttributeError:模块“os"没有属性“uname"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:AttributeError:模块“os"没有属性“uname"
基础教程推荐
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
