V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
wwg1994
V2EX  ›  Python

Python 原生字符串的问题,来个大佬救救我

  •  
  •   wwg1994 · 2018-12-21 17:36:26 +08:00 · 221 次点击
    这是一个创建于 1924 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想对 unicode 编码做字符串的操作,要把 a 转成原生字符串 b,百度不到呀,又不会科学上网,大佬们帮帮我

    a = '\uf85c\ue24c.\uf8e9'

    b = func(a) 我就想找到这样一个方法把 a 转成 b,C 是目标结果

    b = r'\uf85c\ue24c.\uf8e9'

    c = re.sub(r'\..', '', b)

    wwg1994
        1
    wwg1994  
    OP
       2018-12-21 17:37:19 +08:00
    a 是爬虫爬下的一串字符
    chenstack
        2
    chenstack  
       2018-12-21 17:42:53 +08:00   ❤️ 2
    b = a.encode('unicode_escape').decode()
    wwg1994
        3
    wwg1994  
    OP
       2018-12-21 17:45:35 +08:00
    @chenstack 感谢大佬(づ ̄ 3  ̄)づ
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5216 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 09:26 · PVG 17:26 · LAX 02:26 · JFK 05:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.