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.

Revisions

  1. outiy5 created this gist Mar 19, 2020.
    9 changes: 9 additions & 0 deletions ps_2js.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # 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)