且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在输出中打印 Python 版本

更新时间:2023-12-04 10:52:10

尝试

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.