expression - python re.search error TypeError: expected string or buffer -
why
re.search("\.docx", os.listdir(os.getcwd())) yield following error?
typeerror: expected string or buffer
because os.listdir returns list re.search wants string.
the easiest way doing is:
[f f in os.listdir(os.getcwd()) if f.endswith('.docx')] or even:
import glob glob.glob('*.docx') 
Comments
Post a Comment