代码:

  1. import platform
  2.  
  3. def TestPlatform():
  4. print ("----------Operation System--------------------------")
  5. #Windows will be : (32bit, WindowsPE)
  6. #Linux will be : (32bit, ELF)
  7. print(platform.architecture())
  8.  
  9. #Windows will be : Windows-XP-5.1.-SP3 or Windows-post2008Server-6.1.
  10. #Linux will be : Linux-2.6.-.el5-i686-with-redhat-5.3-Final
  11. print(platform.platform())
  12.  
  13. #Windows will be : Windows
  14. #Linux will be : Linux
  15. print(platform.system())
  16.  
  17. print ("--------------Python Version-------------------------")
  18. #Windows and Linux will be : 3.1. or 3.1.
  19. print(platform.python_version())
  20.  
  21. def UsePlatform():
  22. sysstr = platform.system()
  23. if(sysstr =="Windows"):
  24. print ("Call Windows tasks")
  25. elif(sysstr == "Linux"):
  26. print ("Call Linux tasks")
  27. else:
  28. print ("Other System tasks")
  29.  
  30. UsePlatform()

参考博客:原文链接http://www.cnblogs.com/snow-backup/p/4151276.html

  1. import platform
  2.  
  3. def TestPlatform():
  4. return platform.architecture()[]
  5.  
  6. def mysubData(subData):
  7. b = []
  8.  
  9. for i in subData:
  10. try:
  11. if numpy.isnan(i):
  12. i = "Null"
  13. b.append(i)
  14. if TestPlatform() == "64bit":
  15. if isinstance(i, numpy.float64):
  16. b.append(i)
  17. elif isinstance(i, numpy.int64):
  18. b.append(i)
  19. elif TestPlatform() == "32bit":
  20. if isinstance(i, numpy.float32):
  21. b.append(i)
  22. elif isinstance(i, numpy.int32):
  23. b.append(i)
  24. except:
  25. if isinstance(i, str):
  26. if "'" in i:
  27. i.replace("'", "")
  28. elif "%" in i:
  29. i.replace("'", "")
  30. elif "\\" in i:
  31. i.replace("'", "")
  32. b.append(i)
  33. else:
  34. b.append(i)
  35.  
  36. return b

Python判断操作系统类型的更多相关文章

  1. python 判断操作系统类型

    #!/bin/python # import platform def TestPlatform(): print ("----------Operation System--------- ...

  2. Java 判断操作系统类型(适用于各种操作系统)

    Java 判断操作系统类型(适用于各种操作系统) 最近一段时间写一个授权的程序,需要获取很多信息来保证程序不能随意复制使用,必须经过授权才可以. 为了限制用户使用的操作系统,必须有统一的方法来获取才可 ...

  3. python实例[判断操作系统类型]

    参考文献:http://bbs.chinaunix.net/thread-1848086-1-1.html 经常地我们需要编写跨平台的脚本,但是由于不同的平台的差异性,我们不得不获得当前所工作的平台( ...

  4. 深入C#判断操作系统类型的总结详解(转载)

    Windows操作系统的版本号一览 操作系统  PlatformID  主版本号  副版本号  Windows95  1  4  0  Windows98  1  4  10  WindowsMe   ...

  5. C#判断操作系统类型汇总

    Windows操作系统的版本号一览 操作系统 PlatformID 主版本号 副版本号 Windows95 1 4 0 Windows98 1 4 10 WindowsMe 1 4 90 Window ...

  6. C#判断操作系统类型

    操作系统  PlatformID  主版本号  副版本号  Windows95  1  4  0  Windows98  1  4  10  WindowsMe  1  4  90  WindowsN ...

  7. python判断字符串类型

    s为字符串 s.isalnum() 所有字符都是数字或者字母,为真返回 Ture,否则返回 False.(重点,这是字母数字一起判断的!!) s.isalpha() 所有字符都是字母,为真返回 Tur ...

  8. python判断操作系统

    https://www.crifan.com/python_get_current_system_os_type_and_version_info/ 参考:https://stackoverflow. ...

  9. python 判断操作系统以及操作系统版本号

    >>> import platform >>> platform.platform() 'Darwin-17.7.0-x86_64-i386-64bit' > ...

随机推荐

  1. 使用 nw-builder 构建跨平台桌面应用程序

    NW.js 是一个使用 Web 技术创建本地应用的框架,如 HTML.JavaScript 和 CSS.简单地说,当你在使用普通的流程开发一个 Web 应用时,开发完成后,运行一个生成器,将所有东西编 ...

  2. python常用运维脚本实例

    转载  file是一个类,使用file('file_name', 'r+')这种方式打开文件,返回一个file对象,以写模式打开文件不存在则会被创建.但是更推荐使用内置函数open()来打开一个文件 ...

  3. CAS无锁实现原理以及ABA问题

    CAS(比较与交换,Compare and swap) 是一种有名的无锁算法.无锁编程,即不使用锁的情况下实现多线程之间的变量同步,也就是在没有线程被阻塞的情况下实现变量的同步,所以也叫非阻塞同步(N ...

  4. pandas数组(pandas Series)-(2)

    pandas Series 比 numpy array 要强大很多,体现在很多方面 首先, pandas Series 有一些方法,比如: describe 方法可以给出 Series 的一些分析数据 ...

  5. ashx页面返回json字符串|jQuery 的ajax处理请求的纠结问题

    纠结,整了半天的jquery的ajax请求数据. 遇到的问题: 1 ajax方法一直进入error方法里,进入到请求的.ashx页面.这个问题,我未找到是什么原因.反正我使用了一下的代码,就好了. $ ...

  6. [Windows Azure] Managing SQL Database using SQL Server Management Studio

    Managing Windows Azure SQL Database using SQL Server Management Studio You can use Windows Azure SQL ...

  7. Android 编程下实现 Activity 的透明效果

    实现方式一(使用系统透明样式) 通过配置 Activity 的样式来实现,在 AndroidManifest.xml 找到要实现透明效果的 Activity,在 Activity 的配置中添加如下的代 ...

  8. 光照渲染[Unity]

    http://www.unitymanual.com/m/Manual/RenderingPaths.html http://wenku.baidu.com/view/54eca9e09b896802 ...

  9. 【驱动】DM9000网卡驱动分析

    Preface    内核源码版本:linux-2.6.18    网卡驱动·linux内核网络分层结构:http://infohacker.blog.51cto.com/6751239/122114 ...

  10. poj1753(位运算压缩状态+bfs)

    题意:有个4*4的棋盘,上面摆着黑棋和白旗,b代表黑棋,w代表白棋,现在有一种操作,如果你想要改变某一个棋子的颜色,那么它周围(前后左右)棋子的颜色都会被改变(白变成黑,黑变成白),问你将所有棋子变成 ...