Python检测当前操作系统

方法一

import platform

if ('Windows' == platform.system()):
    print('Windows')
elif ('Linux' == platform.system()):
    print('Linux')
else:
    print('Others')

方法二

from sys import platform

if ("linux" == platform) or ("linux2" == platform):
    print("Linux")
elif ("win32" == platform):
    print("Linux")
else:
	print("Others")

你可能感兴趣的:(Python编程,Memos,python,linux,操作系统)