Python + Sublime Text 2, right way to put path of file folder -


a question on way of putting file paths. using python in sublime text 2.

not new topic still don’t it.

a working fine sample (there text file aaa.txt in file folder),

file_folder = 'c:\\abc\\aaa\\' root, dirs, files = os.walk(file_folder).next() txt_file in files:     open(file_folder + txt_file) f:         line in f:             line = line.rstrip('\n')             print line 

it works fine need manually change “\” “\” each time if copy raw path “c:\abc\aaa\” somewhere else.

when put it:

file_folder = r'c:\abc\aaa\' 

it gives:

syntaxerror: eol while scanning string literal 

when put it:

file_folder = r'c:\abc\aaa' 

it gives:

ioerror: [errno 2] no such file or directory: 'c:\\abc\\aaaaaa.txt' 

when put it:

file_folder_text = 'c:\abc\aaa' file_folder = re.escape(file_folder_text) 

it gives:

stopiteration 

how can save manual changes?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -