Any check to see if the code written is in python 2.7 or 3 and above?

后端 未结 4 2011
挽巷
挽巷 2020-12-15 04:10

I have a buggy long python project that I am trying to debug. Its messy and undocumented. I am familiar with python2.7. There are no binaries in this project. The straight f

4条回答
  •  没有蜡笔的小新
    2020-12-15 04:16

    Attempt to compile it. If the script uses syntax specific to a version then the compilation will fail.

    $ python2 -m py_compile foo.py
    $ python3 -m py_compile foo.py
    

提交回复
热议问题