python 2.7 - If a location exist with os.path.isdir by passing a user input variable -


my python code snippet

clname = raw_input ("\n\nenter 7 digits cl number !")  if os.path.isdir("\\\\abc\\\compiler_builds\\\something\\\clname"):                                                             print  "cl exists" 

\\\\abc\\compiler_builds\\something local windows server location. in above code want os.path.dir() check if path \\\\abc\\\compiler_builds\\\something exists inserting clname @ end, given user. have tried specific could. please let me know if need provide more info on , please ignore grammatical or english mistakes.

clname = raw_input ("\n\nenter 7 digits cl number !")  if os.path.isdir("/abc/compiler_builds/something/%s" % clname):                                                             print  "cl exists" 

you interpolate clname string, shown.

you don't need use escaped backslashes, use forwards slashes.


Comments