当我使用json.loads时,你是什么人? [英] What are the u's when I use json.loads?

查看:141
本文介绍了当我使用json.loads时,你是什么人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在编写Python脚本来解析Soundcloud API中的JSON信息,而我只是想知道当我使用json.loads(val)时"u"是什么以及如何将JSON信息存储到没有u的对象?

I've been writing a Python script to parse JSON information from the Soundcloud API, and I was just wondering what the "u"'s are when I use json.loads( val ) and how to store the JSON information to an object without the u's?

即你为什么在这里?

>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]

请参阅此处的解码JSON"部分,以进一步了解我的意思:

See the "Decoding JSON" section here to understand what I mean further:

http://docs.python.org/library/json.html

谢谢!

推荐答案

Unicode字符串.请参见 Python教程.

Unicode strings. See the Python Tutorial.

在Python源代码中,Unicode文字被编写为以'u'或'U'字符为前缀的字符串:u'abcdefghijk'.

In Python source code, Unicode literals are written as strings prefixed with the ‘u’ or ‘U’ character: u'abcdefghijk'.

- Python中的Unicode文字源代码

这篇关于当我使用json.loads时,你是什么人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆