在写python的时候,经常会需要确定当前运行的平台(如操作系统),在python的标准库中就有相关的方法,非常简单。
方法1:platform库的system函数
importplatform
platform.system()
Returnsthe system/OS name, e.g.'Linux', 'Windows', or 'Java'.Anempty string is returned if the valuecannot be determined.
方法2:sys库的platform变量
import sys
sys.platform