A string maybe this
ipath= "./data/NCDC/上海/虹桥/9705626661750dat.txt"
or this
ipath = './data/NCDC/ciampino/6240476818161dat.txt'
How do I know the first string contains chinese?
I find this answer maybe helpful: Find all Chinese text in a string using Python and Regex
but it didn't work out:
import re ipath= "./data/NCDC/上海/虹桥/9705626661750dat.txt" re.findall(ur'[u4e00-u9fff]+', ipath) # => []
The matched string should be unicode as well
>>> import re >>> ipath= u"./data/NCDC/上海/虹桥/9705626661750dat.txt" >>> re.findall(r'[u4e00-u9fff]+', ipath) [u'u4e0au6d77', u'u8679u6865']
2.1m questions
2.1m answers
60 comments
57.0k users