Python-如何将python36命令行中的行保存到.py文件?

Python-如何将python36命令行中的行保存到.py文件?,python,file,save,Python,File,Save,python有一个类似CMD的工具python36。 其中,如果键入一行并按enter键,则获得输出。 我想把我写的东西保存到一个以.py结尾的文件中,我该怎么做? 谢谢。一个简单的演示代码: with open("output.py","w") as fp: while True: line = input("please input:") if line == "": # press enter to exit break

python有一个类似CMD的工具python36。 其中,如果键入一行并按enter键,则获得输出。 我想把我写的东西保存到一个以.py结尾的文件中,我该怎么做?
谢谢。

一个简单的演示代码:

with open("output.py","w") as fp:
    while True:
        line = input("please input:")
        if line == "": # press enter to exit
            break
        fp.write(line+"\n")

一个简单的演示代码:

with open("output.py","w") as fp:
    while True:
        line = input("please input:")
        if line == "": # press enter to exit
            break
        fp.write(line+"\n")

复制和意大利面?复制和意大利面?