Python glob and bracket characters ('[]')

前端 未结 4 1832
一向
一向 2020-12-17 08:22

/Users/smcho/Desktop/bracket/[10,20] directory has \"abc.txt\", but when I run this Python code

import glob
import os.path

path1 = \"/Users/smcho/Desktop/br         


        
4条回答
  •  醉话见心
    2020-12-17 08:48

    You could use path.replace('[', '[[]') to have arbitrary input paths handled by glob correctly.

提交回复
热议问题