0

I've got a problem. I want to write an auto compiler for python, but im so fresh at python, that i dont even know how to write a file multilined. I tried that:

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()

But it didnt work, and /n got just written as string to. pls correct my code, and tell me bout my mistake :)

  • look at this link http://stackoverflow.com/questions/11497376/new-line-python – Ashouri Aug 23 '14 at 14:13
  • Just a hint: do escape correctly; instead of `"c:\Python"` write `"c:\\Python"` or `r"c:\Python"` :) Also it looks a bit nicer to use string formatting instead of `"a"+b+"c"+d` - see `format`: https://docs.python.org/2/library/string.html#format-string-syntax or templates: https://docs.python.org/2/library/string.html#template-strings or even tools like http://jinja.pocoo.org/ – Messa Aug 23 '14 at 14:16

1 Answers1

3

You may want to use the correctly escaped

"\n"

instead of

"/n"
TidB
  • 1,749
  • 1
  • 12
  • 14