The argparse
library in python doesn't work for the path, containing space, and '\' (backslash) at the end.
The parser in argparse parses the backslash at the end of path to " (double quotation).
The code below is sample that has same problem.
import argparse
if __name__=="__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-w', '--weight', type=str)
args = parser.parse_args()
print(args.weight_path)
For example in the PowerShell,
PS > python sample.py -w ".\test test\"
.\test test"
It does work for the path which doesn't containing space.
PS > python sample.py -w ".\testtest\"
.\test test\
PS > python sample.py -w "testtest\"
test test\
PS > python sample.py -w "testtest"
test test
Is there any problem for using argparse with PowerShell?
I don't even know how to search for this problem...