How can I check what version of the Python Interpreter is interpreting my script?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
With
six
module, you can do it by:Check Python version:
python -V
orpython --version
orapt-cache policy python
you can also run
whereis python
to see how many versions are installed.I like
sys.hexversion
for stuff like this.http://docs.python.org/library/sys.html#sys.hexversion
sys.version gives you what you want, just pick the first number :)
If you are working on linux just give command
python
output will be like thisJust for fun, the following is a way of doing it on CPython 1.0-3.7b2, Pypy, Jython and Micropython. This is more of a curiosity than a way of doing it in modern code. I wrote it as part of http://stromberg.dnsalias.org/~strombrg/pythons/ , which is a script for testing a snippet of code on many versions of python at once, so you can easily get a feel for what python features are compatible with what versions of python: