2025年2月24日 星期一 甲辰(龙)年 腊月廿四 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > Python

python --检测当前操作系统

时间:08-13来源:作者:点击数:31

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")
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐