亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Industrial programming >> Python

检查代码中的 Python 版本:要求最低

您可以在代码中检查 Python 版本,以确保您的用户没有使用不兼容的版本运行您的脚本。使用这个简单的检查:

import sys

if not sys.version_info > (2, 7):
   # berate your user for running a 10 year
   # python version
elif not sys.version_info >= (3, 5):
   # Kindly tell your user (s)he needs to upgrade
   # because you're using 3.5 features

Python

  1. Python 数据类型
  2. Python 运算符
  3. Python pass 语句
  4. Python 函数参数
  5. Python字典
  6. Python 迭代器
  7. Python 闭包
  8. Python 日期时间
  9. Python 睡眠()
  10. Python For &While 循环:枚举、中断、继续语句
  11. Python time.sleep():为您的代码添加延迟(示例)
  12. Python 检查文件是否存在 |如何在 Python 中检查目录是否存在