在Python中,你可以使用`platform`模块来获取操作系统的相关信息。下面是一个示例代码: ```python import platform # 获取操作系统的名称和版本 os_name = platform.system() os_version = platform.release() # 获取操作系统的架构 os_arch = platform.machine() # 获取计算机的主机名 hostname = platform.node() # 打印操作系统信息 print(f"Operating System: {os_name} {os_version}") print(f"Architecture: {os_arch}") print(f"Hostname: {hostname}") ``` `platform`模块的结果是根据当前运行Python脚本的操作系统环境提供的信息。 [2023-10-04 17:42:24 | AI写代码神器 | 416点数解答]