折腾:
【未解决】Mac中如何从命令行终端中启动wine
期间,想要去Python中,查看当前系统的信息,比如基本硬件和cpu等,软件的系统平台,版本等相关信息。
之前记得有个sys,但是只记得一个sys.platform,比较简单。
想要查看更多的详细的系统信息。
✘ ⚙ xxx@xx ~ wine python 0009:fixme:msvcrt:_configure_wide_argv (1) stub 0009:fixme:msvcrt:_initialize_wide_environment stub Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.platform 'win32' >>> platform.machine() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'platform' is not defined >>> import platform >>> platform.machine() 'AMD64' >>> platform.version() '5.1.2600' >>> platform.platform() 'Windows-XP-5.1.2600' >>> platform.uname() uname_result(system='Windows', node=‘xxx021', release='XP', version='5.1.2600', machine='AMD64', processor='AMD64 Family 6 Model 142 Stepping 10, GenuineIntel') >>> platform.system() 'Windows' >>> platform.processor() 'AMD64 Family 6 Model 142 Stepping 10, GenuineIntel' >>> import os >>> os.uname() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'os' has no attribute 'uname' >>>
>>> import socket >>> socket.gethostname() ‘xxx021' >>> socket.getfqdn() 0009:err:winediag:WS_getaddrinfo Failed to resolve your host name IP '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa' >>> platform.release() 'XP'
此处不想安装第三方库:psutil
>>> import uuid >>> uuid.getnode() 0
【总结】
此处如果只是查看当前系统的基本的概要的软硬件的信息的话,则可以:
import platform platform.uname()
即可。
比如:
Mac
python Python 3.8.0 (default, Jan 6 2020, 10:33:50) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.uname() uname_result(system='Darwin', node=‘xxx021', release='18.7.0', version='Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64', machine='x86_64', processor='i386')
Mac中Wine == Windows XP:
wine python 002a:fixme:msvcrt:_configure_wide_argv (1) stub 002a:fixme:msvcrt:_initialize_wide_environment stub Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.uname() uname_result(system='Windows', node=‘xxx021', release='XP', version='5.1.2600', machine='AMD64', processor='AMD64 Family 6 Model 142 Stepping 10, GenuineIntel')
如果想要查看详细的各项信息,则是:
代码:
import platform platform.uname() platform.machine() platform.platform() platform.system() platform.release() platform.version() platform.processor() import sys sys.platform import socket socket.gethostname() socket.getfqdn()
Mac输出效果:
✘ ⚙ xxx@xxx ~ python Python 3.8.0 (default, Jan 6 2020, 10:33:50) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.uname() uname_result(system='Darwin', node=‘xxx021', release='18.7.0', version='Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64', machine='x86_64', processor='i386') >>> platform.uname() uname_result(system='Darwin', node=‘xxx021', release='18.7.0', version='Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64', machine='x86_64', processor='i386') >>> platform.platform() 'macOS-10.14.6-x86_64-i386-64bit' >>> platform.system() 'Darwin' >>> platform.release() '18.7.0' >>> platform.version() 'Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64' >>> platform.processor() 'i386' >>> import sys >>> sys.platform 'darwin' >>> import socket >>> socket.gethostname() ‘xxx021' >>> socket.getfqdn() ‘xxx021' >>>
Mac中Wine输出效果:
✘ ⚙ xxx@xxx ~ wine python 002a:fixme:msvcrt:_configure_wide_argv (1) stub 002a:fixme:msvcrt:_initialize_wide_environment stub Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.uname() uname_result(system='Windows', node=‘xxx021', release='XP', version='5.1.2600', machine='AMD64', processor='AMD64 Family 6 Model 142 Stepping 10, GenuineIntel') >>> platform.machine() 'AMD64' >>> platform.platform() 'Windows-XP-5.1.2600' >>> platform.system() 'Windows' >>> platform.release() 'XP' >>> platform.version() '5.1.2600' >>> platform.processor() 'AMD64 Family 6 Model 142 Stepping 10, GenuineIntel' >>> import sys >>> sys.platform 'win32' >>> import socket >>> socket.gethostname() ‘xxx021' >>> socket.getfqdn() 002a:err:winediag:WS_getaddrinfo Failed to resolve your host name IP '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa' >>>
注:
此处很明显:
platform.platform() == “%s-%s-%s” % (platform.system(), platform.release(), platform.version())