的字符串,也許這Python:檢查一個字符串是否包含漢字?
ipath= "./data/NCDC/上海/虹橋/9705626661750dat.txt"
或本
ipath = './data/NCDC/ciampino/6240476818161dat.txt'
我怎麼知道第一個字符串包含中國?
我覺得這個答案也許有幫助: Find all Chinese text in a string using Python and Regex
,但它沒有工作:
import re
ipath= "./data/NCDC/上海/虹橋/9705626661750dat.txt"
re.findall(ur'[\u4e00-\u9fff]+', ipath) # => []
你使用Python 2嗎?在Python 3中,當聲明正則表達式時,[似乎工作](https://ideone.com/lPHSky)沒有'r'。 –
'ipath = u「./ data/NCD',錯過字符串前的'u' – Tushar
看看這個[Python 2 demo](https://ideone.com/i0unNw) - 它適合你嗎? –