我遇到了问题。我想为python编写一个自动编译器,但我在python中很新鲜,我甚至不知道如何编写多行文件。 我试过了:
import os
pythonversion = str(input("Pythonversion [no '.']:"))
exename = str(input("Programname:"))
exeversion = str(input("Programversion:"))
exedescription = str(input ("Programdescription:"))
exeoldname = str(input("Programs python file [name.py]:"))
content1 = "from cx_Freeze import setup, Executable"
content2 = 'setup( name = "'+exename+'" , version = "'+exeversion+'", description ="'+exedescription+'" , executables = [Executable("'+exeoldname+'")] , )'
file = open("c:\Python"+pythonversion+"\setup.py","w")
file.write(str(content1))
file.write("/n")
file.write(str(content2))
file.close()
但它没有用,而且/ n刚刚写成字符串。请更正我的代码,并告诉我回合我的错误:)
答案 0 :(得分:3)
您可能想要使用正确转义的
"\n"
而不是
"/n"