光阴似箭催人老,日月如移越少年。
data = { "title": "魅族 32G 魅蓝note5" } import json print(json.dumps(data, ensure_ascii=False, encoding="utf-8"))
chcp 65001
Just type it directly in the terminal.
ლ(╹◡╹ლ), um, maybe, huh?
.encode('utf-8') try it
With python3, you don’t have these worries anymore
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from bs4 import BeautifulSoup >>> import requests >>> data = requests.get('http://zhuanzhuan.58.com/detail/807158202296418308z.shtml').content >>> soup = BeautifulSoup(data,'lxml') >>> title = soup.select('.box_left_top h1')[0].text.encode('utf-8') >>> print type(title) <type 'str'> >>> print title 魅族 32G 魅蓝note5 >>> test_data = {'title':title} >>> print test_data {'title': '\xe9\xad\x85\xe6\x97\x8f 32G \xe9\xad\x85\xe8\x93\x9dnote5'} >>> print repr(test_data).decode("unicode-escape") {'title': u'魅族 32G 魅蓝note5'}
The method works, thank you
Just type it directly in the terminal.
ლ(╹◡╹ლ), um, maybe, huh?
.encode('utf-8') try it
With python3, you don’t have these worries anymore
The method works, thank you