0

I have read How do I un-escape a backslash-escaped string in python? (How do I un-escape a backslash-escaped string in python?) and the answer doesn't work, perhaps because I'm running Windows.

In [1]: sql = '''
SELECT {column_specs}
    FROM {tables}
    WHERE year = {year} AND game_ref = games.id AND
        {id_matches} AND
        EVENT_CD IN ({event_codes})'''
In [2]: sql.decode('string_escape')
Out[2]: '\nSELECT {column_specs}\n    FROM {tables}\n    WHERE year = {year} AND game_ref = games.id AND\n        {id_matches} AND\n        EVENT_CD IN ({event_codes})'
Community
  • 1
  • 1
Dvd Avins
  • 438
  • 5
  • 10
  • 1
    Your example doesn't have any unescaped strings in it. Are you trying to get rid of the line feeds in the multiline string? What do you want the answer to look like? – tdelaney Dec 09 '15 at 22:41
  • "That's it. I forgot I needed the print statements to make it work." Voting to close as not reproducible. – Karl Knechtel Aug 05 '22 at 03:59

1 Answers1

2

Try

print sql.decode('string_escape')

Output

SELECT {column_specs}
    FROM {tables}
    WHERE year = {year} AND game_ref = games.id AND
        {id_matches} AND
        EVENT_CD IN ({event_codes})
Adem Öztaş
  • 20,457
  • 4
  • 34
  • 42