V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
huanghuahua
V2EX  ›  问与答

python 正则匹配中文问题。

  •  
  •   huanghuahua · Oct 30, 2015 · 1307 views
    This topic created in 3832 days ago, the information mentioned may be changed or developed.

    我扒下来的豆瓣登陆网页源码里有验证码信息,有一行代码是这样的:

    <span id="captcha_block" class="pl">请输入上图中的单词</span>

    我想要用正则匹配,里面的 请输入上图中的单词 这几个中文代码如下:
    pattern = re.compile(r'<span id="captcha_block" class="pl">(.*?)</span>',re.S)
    result = re.search(pattern,contents)
    print result

    ccontents 就是源码,但是运行结果是 none ,就是匹配失败了,请问了,要怎么样来匹配中文,以这个为例,在网上搜了很多,讲的都是编码, gtk utf-8 的没看懂,请大家帮助一下,谢谢。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1829 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 16:22 · PVG 00:22 · LAX 09:22 · JFK 12:22
    ♥ Do have faith in what you're doing.