I wrote a python script needed 2 command line arguments, and there are some '&'s in the 2nd parameter. And I received the error zsh parse error near &', so I tried to quoted and double-quoted these 2 parameters but the result went wrong. The code is simplified as below:
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&e&f'
print signature(secret_access_key, string_to_sign)
print signature(sys.argv[1], sys.argv[2])
print sys.argv[2] == string_to_sign
and following is the configuration in pycharm

print sys.argv[2] == string_to_sign returned False and
The result of signature(secret_access_key, string_to_sign) is what I expected, but I need to pass these 2 parameters in command line.
So is there any way to escape '&' and '\n' in command line?