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
Post a Comment