你好,我需要一些帮助,我正在使用 python 版本 3/2,我想在 python 脚本上创建一个系统检测,我该如何解决这样的问题:
try:
import platform
python_sysvers = platform.python_version()
if (self.linux_prompt()):
if int(python_sysvers[0]) == True:
command = input("")
else:
if (self.linux_prompt()):
if int(python_sysvers[0]) == True:
return input(self.getlinux_prompt())
while True:
if command == 'terminate':
if 'terminate' in command:
self.quit = True
return
self.sock.send(command)
ok 从我上面写的代码来看,如果它是 python 版本 2,我的目标是调用“raw_input()”,但如果它是更高版本,则该函数引用“input()”函数,那么当我们运行代码时如何实现它它使用 python 版本 2 或版本 3,代码可以兼容运行,如果我使用 python 版本 3 运行代码,它不会转移到 python 版本 2 代码,...上面的代码旨在更容易维护谢谢你^^
解决如何在python 3上调用python 2代码