推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
leetao102
V2EX  ›  Python

请问一下,名字 地址 电话 正则如何正则匹配

  •  
  •   leetao102 · Jul 16, 2015 · 3785 views
    This topic created in 3953 days ago, the information mentioned may be changed or developed.

    var shopInfo = "{\"name\":\"承宣\",\"address\":\"校园路香江公寓1号稀土开发区\",\"position\":\"109.855573,40.627727\",\"entId\":1200,\"isFav\":0,\"tel\":\"13500104392\"}";

    6 replies    2015-07-16 12:35:01 +08:00
    wkdhf233
        1
    wkdhf233  
       Jul 16, 2015
    你这不是JSON吗,干嘛要用正则去匹配。。
    Septembers
        2
    Septembers  
       Jul 16, 2015   ❤️ 1
    >>> import re, json
    >>> shopInfo = 'var shopInfo = "{\"name\":\"承宣\",\"address\":\"校园路香江公寓1号稀土开发区\",\"position\":\"109.855573,40.627727\",\"entId\":1200,\"isFav\":0,\"tel\":\"13500104392\"}";'
    >>> re.search('"(.*)";$', shopInfo).group(1)
    '{"name":"承宣","address":"校园路香江公寓1号稀土开发区","position":"109.855573,40.627727","entId":1200,"isFav":0,"tel":"13500104392"}'
    >>> json.loads(_)
    {'entId': 1200, 'address': '校园路香江公寓1号稀土开发区', 'position': '109.855573,40.627727', 'isFav': 0, 'tel': '13500104392', 'name': '承宣'}
    >>>
    Twinkle
        3
    Twinkle  
       Jul 16, 2015
    JSON.parse(shopInfo)
    leetao102
        4
    leetao102  
    OP
       Jul 16, 2015
    @wkdhf233 抓取一个网页,然后返回这个。。
    leetao102
        5
    leetao102  
    OP
       Jul 16, 2015
    khan
        6
    khan  
       Jul 16, 2015
    这不是妥妥的 json 么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1079 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:55 · PVG 06:55 · LAX 15:55 · JFK 18:55
    ♥ Do have faith in what you're doing.