• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > Python判断操作系统类型代码分享

Python判断操作系统类型代码分享

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了python 文件操作,python 列表操作,python 字符串操作,python字典操作,python 数组操作等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

经常地我们需要编写跨平台的脚本,但是由于不同的平台的差异性,我们不得不获得当前所工作的平台(操作系统类型)。

代码如下:

import platform

def TestPlatform():
    print ("----------Operation System--------------------------")
    #Windows will be : (32bit, WindowsPE)
    #Linux will be : (32bit, ELF)
    print(platform.architecture())

    #Windows will be : Windows-XP-5.1.2600-SP3 or Windows-post2008Server-6.1.7600
    #Linux will be : Linux-2.6.18-128.el5-i686-with-redhat-5.3-Final
    print(platform.platform())

    #Windows will be : Windows
    #Linux will be : Linux
    print(platform.system())

    print ("--------------Python Version-------------------------")
    #Windows and Linux will be : 3.1.1 or 3.1.3
    print(platform.python_version())

def UsePlatform():
  sysstr = platform.system()
  if(sysstr =="Windows"):
    print ("Call Windows tasks")
  elif(sysstr == "Linux"):
    print ("Call Linux tasks")
  else:
    print ("Other System tasks")
   
UsePlatform()
</div>

</div>

您可能想查找下面的文章:

  • python列表的常用操作方法小结
  • python文件操作相关知识点总结整理
  • python文件操作相关知识点总结整理
  • Python编程中的文件操作攻略
  • Python编程中的文件操作攻略
  • 在Python中操作时间之tzset()方法的使用教程
  • python修改操作系统时间的方法
  • Python实现获取操作系统版本信息方法
  • Python实现获取操作系统版本信息方法
  • Python判断操作系统类型代码分享

相关文章

  • 深入讲解Python函数中参数的使用及默认参数的陷阱
  • 用Python和MD5实现网站挂马检测程序
  • python&MongoDB爬取图书馆借阅记录
  • Python图像灰度变换及图像数组操作
  • 分享一下Python 开发者节省时间的10个方法
  • 利用Python生成文件md5校验值函数的方法
  • Windows下Python2与Python3两个版本共存的方法详解
  • Python 错误和异常小结
  • Python多线程编程(一):threading模块综述
  • python装饰器decorator介绍

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 在Ubuntu系统下安装使用Python的GUI工具wxPython
    • tensorflow模型保存、加载之变量重命名实例
    • Python ORM框架SQLAlchemy学习笔记之数据添加和事务回滚介绍
    • python端口扫描系统实现方法
    • 编写Python的web框架中的Model的教程
    • python 循环while和for in简单实例
    • 使用Python进行稳定可靠的文件操作详解
    • 从零开始学Python第八周:详解网络编程基础(socket)
    • Python2.x版本中基本的中文编码问题解决
    • 使用Python判断质数(素数)的简单方法讲解

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有