Symbols must be saved in Unicode, and can be matched according to Unicode code.
Special characters in 1.csv can be found in the Excel caret, and the Unicode code for the symbol is noted. For example, this solid square Unicode code is 25a0:
2. Need to query other code can be based on this Code search, (of course, this example with the word code): such as Unicode 25a0 python, you can get the code in each encoding method, this example URL:
Http://www.fileformat.info/info/unicode/char/25a0/index.htm looking for Python is:
UTF-8 (hex) |
0xe2 0x96 0xA0 (e296a0) |
UTF-8 (binary) |
11100010:10010110:10100000 |
UTF-16 (hex) |
0x25a0 (25A0) |
UTF-16 (decimal) |
9,632 |
UTF-32 (hex) |
0x000025a0 (25A0) |
UTF-32 (decimal) |
9,632 |
C/c++/java Source Code |
"\u25a0" |
Python Source Code |
U "\u25a0" |
3.
#-*-Coding:utf-8-*-import rea=u "\u25a0" b=u "high Risk" d= "%s%s"% (A, b) d1=d.encode (' GBK ') #decode to match text to get content, formerly utf8p= Re.compile (". *\s*%s\s*.*"%d1) with open ("B.csv", "R") as R: for I in R: #print I Line=i.strip (). Split ("#") [ 7] Print line if P.search (line): count+=1print "Count =%s"%count
You also need to learn the coding method carefully: http://python.jobbole.com/86670/
Python matches special symbols in CSV file such as high-risk black block