问题
Related: Is there a standard way to make sure a python script will be interpreted by python2 and not python3?
Apparently not all distros ship with a python3
symlink, either. #!/usr/bin/env python3
causes a no-such-file-or-directory error. What shebang line should I use if my script requires any version of Python 3?
回答1:
import sys
try:
assert sys.version_info[0] == 3
except:
print "ERROR NOT PYTHON 3!"
sys.exit()
来源:https://stackoverflow.com/questions/19625768/is-there-a-standard-way-to-make-sure-a-python-script-will-be-interpreted-by-pyth