Pass dict as an argument over SSH to Python script
问题 I am trying to pass dict arguments using the ssh command via the os module: os.system(f'ssh remote_host python -u - {dict1} {dict2} < local_script.py') I am getting an error: sh:line:0 syntax error near unexpected token (' What is the right syntax to pass dict as an argument? If I pass string instead of dict, it works fine. Any suggestions? 回答1: Use json and urlencode. import urllib.parse import json dict1_j = urllib.parse.quote(json.dumps(dict1)) dict2_j = urllib.parse.quote(json.dumps(dict2