Python sys.argv to preserve ' ' or “”
问题 terminal: python test.py blah='blah' in test.py print sys.argv ['test.py', 'blah=blah'] <------------ How can blah arg preserve its '' OR Is there a way to know if an arg is wrap with either "" or ''? 回答1: Your shell removes the quotes before invoking Python. This is not something Python can control. Add more quotes: python test.py "blah='blah'" which can also be placed anywhere in the argument: python test.py blah="'blah'" or you could use backslash escapes: python test.py blah=\'blah\' to