推荐学习书目
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
leartang
V2EX  ›  Python

企业微信通讯录同步创建用户姓名不显示中文求助

  •  
  •   leartang · May 28, 2021 · 1911 views
    This topic created in 1818 days ago, the information mentioned may be changed or developed.
    python 3.9 用的 requests.post

    empinfo = {
    "userid": "%s" %loginid,
    "name": "%s" %name,
    "mobile": "%s" %mobile,
    "department": "%s" %deptid,
    }
    send_empinfo = (bytes(json.dumps(empinfo), 'utf-8'))


    json.dumps 解析为
    b'{"userid": "55555", "name": "\\u6d4b\\u8bd5", "mobile": "13912345678", "department": "888888"}'

    企业微信的姓名显示为 \u6d4b\u8bd5


    大佬救命...
    6 replies    2021-05-28 22:21:15 +08:00
    frostming
        1
    frostming  
       May 28, 2021
    post 的话,requests.post(url, json=empinfo)就行了啊,为啥要自己 dumps
    InkAndBanner
        2
    InkAndBanner  
       May 28, 2021
    编码问题 unicode
    renmu123
        3
    renmu123  
       May 28, 2021
    r = response.post(url)
    r.json()
    leartang
        4
    leartang  
    OP
       May 28, 2021 via Android
    @frostming 改了还是不行,关键是我用原来的早上成功过一次。这样创建组织架构中文也都正常🤣🤣🤣
    cz5424
        5
    cz5424  
       May 28, 2021
    标准编码问题,楼主太会绕弯了; print('\u6d4b\u8bd5')
    发 json
    data = {}
    r = response.post(url, json=data)
    收 json
    r = response.post(url)
    r.json()
    cz5424
        6
    cz5424  
       May 28, 2021
    更正上面,是 requests.post
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3586 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 71ms · UTC 05:01 · PVG 13:01 · LAX 22:01 · JFK 01:01
    ♥ Do have faith in what you're doing.