Parsing Command line arguments in python which has spaces

According to MS: https://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx

Backslashes are interpreted literally, unless they immediately precede a double quotation mark.

I'm wondwring if Python on Windows uses this method: https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx

To parse the command line to create sys.argv. In theory it should do it.


You pass the folder name wrapped in quotes:

test.py "D:\test\File Name"

sys.argv[1] will contain the folder path, spaces included.

If for some reason you cannot quote the folder name, you will need to use the ctypes module and use the Win32 API's GetCommandLine function. Here's a functional example.