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"


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -