title: How to pass escape characters as command line parameters using python
body: <p>I wrote a python script needed 2 command line arguments, and there are some <code>'&amp;'</code>s in the 2nd parameter. And I received the error zsh parse error near &amp;', so I tried to quoted and double-quoted these 2 parameters but the result went wrong. The code is simplified as below:  </p>
  
  <pre><code>import base64, hmac, urllib, sys  
  from hashlib import sha256  
  def signature(secret_access_key, string_to_sign):  
      h = hmac.new(secret_access_key, digestmod=sha256)
      h.update(string_to_sign)
      sign = base64.b64encode(h.digest()).strip()  
      return urllib.quote_plus(sign)  
  if __name__ == '__main__':  
      secret_access_key = 'a'  
      string_to_sign = 'b\nc\nd&amp;e&amp;f'  
      print signature(secret_access_key, string_to_sign)  
      print signature(sys.argv[1], sys.argv[2])  
      print sys.argv[2] == string_to_sign  
  </code></pre>
  
  <p>and following is the configuration in pycharm<br>
  <a href="https://i.stack.imgur.com/idsOo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/idsOo.png" alt="enter image description here"></a><br>
  <code>print sys.argv[2] == string_to_sign</code> returned <code>False</code> and<br>
  The result of <code>signature(secret_access_key, string_to_sign)</code> is what I expected, but I need to pass these 2 parameters in command line.<br>
  So is there any way to escape <code>'&amp;'</code> and <code>'\n'</code> in command line?</p>