2to3.6: python 转换挂起

2to3.6: python conversion hanging

你好,我有一些动态生成的 python code 生成 python2 代码,这个 python 生成的代码被执行,然后它的输出被下游应用程序使用,问题我我的代码转换似乎挂在这些行

RefactoringTool: Files that were modified:
RefactoringTool: x.py

谁能帮我看看哪里出了问题。

python_code = """
def greet(name):
    print("Hello, {0}!".format(name))
print "What's your name?"
name = input()
greet(name)
"""
with open('x.py', 'a') as the_file:
    the_file.write(python_code)
import subprocess
subprocess.run(["2to3-3.6", "-w", 'x.py', "/dev/null"])
op = subprocess.check_output(["python3",  'x.py'])
subprocess.run("rm", "-rf" ,"x.py")
subprocess.run("rm", "-rf" ,"x.py.bak")
print(op)

您正在执行 x.py 文件,该文件正在等待 input()

按回车键,您的脚本将结束