Advertisement
tastypear

比较输入和抓取到unicode串

Apr 3rd, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. #python
  2. #比较输入和抓取到unicode中文串
  3. def ApkNameIsRight(keyword,apkName):
  4.     keyword = keyword.decode("GB2312") #用户输入
  5.     return keyword==hex2u(apkName)
  6.  
  7. #把"中文"转u"中文"真有这么烦么...
  8. def hex2u(hexStr):
  9.     result = ''
  10.     for i in range(len(hexStr)/6):
  11.         result += unichr(int(hexStr[i*6+2:i*6+6], 16))
  12.     return result
  13.  
  14. u = "\u5df2\u7248" #假设抓取到的格式...混合字串还得改OJZ
  15. x = raw_input("x")
  16. print ApkNameIsRight(x,u)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement