Home
Sign Up
Sign In
推荐学习书目
›
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
V2EX
›
Python
html 文件以 utf-8 编码储存了 \u6211\u5728\u5317\u4eac 这样字符,现在需要在 Python 中将这些解码为 utf-8 ,应该怎么做?
INT21H
·
Jun 13, 2012
· 6205 views
This topic created in 5149 days ago, the information mentioned may be changed or developed.
utf
u6211
u5728
4 replies
•
1970-01-01 08:00:00 +08:00
1
fengluo
Jun 13, 2012
print u'\u6211\u5728\u5317\u4eac'.encode('utf-8')
2
INT21H
OP
Jun 13, 2012
@
fengluo
问题是是个 html 文件,基本上都是这种 href=\"javascript:void(0);\">\u8f6c\u53d1<\/a> ,所以需要先 re 匹配到 \uXXXX 然后才能 encode ,该怎么做呢。。
3
cute
Jun 13, 2012
3
'\u6211\u5728\u5317\u4eac'.decode('raw_unicode_escape')
4
INT21H
OP
Jun 13, 2012
@
cute
十分感谢!
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
2792 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: ce1cc7fc · 35ms ·
UTC 07:08
·
PVG 15:08
·
LAX 00:08
·
JFK 03:08
♥ Do have faith in what you're doing.
❯