在输出中打印 Python 版本 [英] Printing Python version in output

查看:52
本文介绍了在输出中打印 Python 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从我的脚本打印当前 Python 安装的版本号?

How can I print the version number of the current Python installation from my script?

推荐答案

尝试

import sys
print(sys.version)

这将打印完整的版本信息字符串.如果您只想要 python 版本号,那么 Bastien Léonard 的解决方案是最好的.您可能想要检查整个字符串,看看您是否需要它或它的一部分.

This prints the full version information string. If you only want the python version number, then Bastien Léonard's solution is the best. You might want to examine the full string and see if you need it or portions of it.

这篇关于在输出中打印 Python 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆