Python判断操作系统类型
来源:互联网 发布:第一军团永远忠诚知乎 编辑:程序博客网 时间:2024/06/05 22:54
本文作者为吕浪(Victor Lv),转载请注明出处。
python(2.7) check the os type running on:
1. use sys.platform:
windows: >>> import sys >>> sys.platform >>> 'win32'linux >>> import sys >>> sys.platform >>> 'linux2'
2. use platform.system():
windows: >>> import platform >>> platform.system() >>> 'Windows'linux: >>> import platform >>> platform.system() >>> 'Linux'
3. Judge the os type:
We can use "=="(equal) to judge whether the os is window or linux, or we can use string.startwith() function to check it: if sys.platform.startswith('freebsd'): # FreeBSD-specific code here... elif sys.platform.startswith('linux'): # Linux-specific code here...
Reference:
platform — Access to underlying platform’s identifying data
阅读全文
0 0
- python判断操作系统类型
- python判断操作系统类型
- python判断操作系统类型
- python判断操作系统类型
- python 判断操作系统类型
- python[判断操作系统类型]
- Python判断操作系统类型
- python小点心--判断操作系统类型
- python技巧31[判断操作系统类型]
- python技巧31[判断操作系统类型]
- python技巧31[判断操作系统类型]
- javascript判断操作系统类型
- c++判断操作系统类型
- bat判断操作系统类型
- vc判断操作系统类型
- Perl判断操作系统类型
- 判断操作系统类型
- Java_判断操作系统类型
- 卷积神经网络
- JDBC核心类(接口)介绍
- 单链表的逆置
- Window 2003 Server R2安装IIS时总提示“需要Service Pack 2 CD-Rom&nb
- linux开启两个tomcat
- Python判断操作系统类型
- shell常用命令
- Spring全家桶(三)Spring SpEL
- call_user_func
- 直接通过配置文件来指定log文件的输出地址
- 双向链表
- C++ 获得指定目录下的所有文件名称
- Android 从输入设备获取消息
- Schema和DTD的区别