I want to write a script (generate_script.py) generating another python script (filegenerated.py)
So far i have created generate_script.py:
import os
fil
Try using \n and \t
import os
filepath = os.getcwd()
def MakeFile(file_name):
temp_path = filepath + file_name
file = open(file_name, 'w')
file.write('def print_success():\n')
file.write('\tprint "sucesss"')
file.close()
print 'Execution completed.'
to output
def print_success():
print "sucesss"
or multiline
import os
filepath = os.getcwd()
def MakeFile(file_name):
temp_path = filepath + file_name
file = open(file_name, 'w')
file.write('''
def print_success():
print "sucesss"
''')
file.close()
print 'Execution completed.'