sys - Read argument with spaces from windows cmd Python -
i'm trying read arguments spaces in windows cmd.
so here code.
from avl_tree import * import sys,os if __name__ == '__main__': avl = avltreemap() infile = sys.argv[1] + '.txt' avl._preprocessing(infile) avl._interface(infile)
i've written sys.argv[1] since i'm gonna type in cmd following:
python filename.py textfilename
but if text file has spaces in name won't work that. suggestions?
thanks in advance.
this hacky fix, , wouldn't suggest because mess other arguments might need add later this:
infile = " ".join(sys.argv[1:]) + '.txt'
so if run program this:
python filename.py file name
infile equal "my file name.txt"