python - How to deal with a quotation-mark at the end of a string literal? -


i have script generates simple python script. replaces @test@ in

important_text='''@text@''' 

with string can contain ' , " symbols. if ends ' python script broken. how can avoid happening? not want saved text altered contentwise. no additional spaces etc.

template = 'important_text=@text@' value = '''he said "no don't".''' script = template.replace('@text@', repr(value)) print(script)  # important_text='he said "no don\'t".' 

Comments

Popular posts from this blog

Add new key value to json node in java -

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

javascript - Highcharts Synchronized charts with missing data points -