我尝试检查当前版本是否为 3,如果是,则切换到 python2:
#!/usr/bin/python
import sys, os
if sys.version_info[0] != 2:
os.execl("/usr/bin/", "python2", *sys.argv)
print(sys.version_info[:])
但是这个脚本返回这个错误:
Traceback (most recent call last):
File "./a.py", line 6, in <module>
os.execl("/usr/bin/", "python2", *sys.argv)
File "/usr/lib/python3.3/os.py", line 531, in execl
execv(file, args)
PermissionError: [Errno 13] Permission denied
我错过了什么?