Skip to content

Instantly share code, notes, and snippets.

@outiy5
Created March 19, 2020 09:22
Show Gist options
  • Save outiy5/eaf0c1f596265e005787a45c2a6caad9 to your computer and use it in GitHub Desktop.
Save outiy5/eaf0c1f596265e005787a45c2a6caad9 to your computer and use it in GitHub Desktop.
[convert python string to javascript string] #python
# https://stackoverflow.com/questions/10395319/python-convert-str-to-javascript-literal-string
import json
jsstring = """
foo "bar"
"""
print 'function dosomething () { return %s.toLowerCase(); }' % json.dumps(jsstring)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment