python unicode
2015-05-31 21:57
585 查看
[b]Python.org[/b]
首先感谢python完善的文档,文档从1968年 the American Standard Code (ASCII)开始讲述。
类型分别如下:
字典类型(以后把这个栗子再完善点):
最典型的的是根据ERRORCODE的值来判断是否要取“获得“的结果,
结果如下:
[b]拓展[/b]
更便捷、完善的处理方式?
中文字符输入、输出
首先感谢python完善的文档,文档从1968年 the American Standard Code (ASCII)开始讲述。
print(type(response)) print(type(response['ERRORCODE'])) print(type(response['RESULT']))
类型分别如下:
<type 'dict'> <type 'unicode'> <type 'unicode'>
字典类型(以后把这个栗子再完善点):
dict_demo = { "ERRORCODE": unicode(0), "RESULT": { "accountID": "abc", "nickName": "123", "tuple": (1,2,3), "list": [1,2,3], "set":{1,3}, "dict":{1:1,2:"what?"} } }
最典型的的是根据ERRORCODE的值来判断是否要取“获得“的结果,
origin_data = dict_demo['ERRORCODE'] print("---------------------") print("before encode utf-8:") print("value:", origin_data) print("type", type(origin_data)) utf8_version = origin_data.encode('utf-8') print("---------------------") print("after encode utf-8:") print("value:", utf8_version) print("type", type(utf8_version)) decode_data = utf8_version.decode('utf-8') print("---------------------") print("then decode data back:") print("value:", decode_data) print("type", type(decode_data))
结果如下:
--------------------- before encode utf-8: ('value:', u'0') ('type', <type 'unicode'>) --------------------- after encode utf-8: ('value:', '0') ('type', <type 'str'>) --------------------- then decode data back: ('value:', u'0') ('type', <type 'unicode'>)
[b]拓展[/b]
更便捷、完善的处理方式?
中文字符输入、输出
相关文章推荐
- Python Web运行环境搭建
- 多线程
- Python图像处理(6):分离土壤与植物
- .T in numpy
- Python 2.7.x 和 3.x 版本的重要区别
- python re 模块 findall 函数用法简述
- estimated parameters that ends with underscore in scikit
- reshape in numpy
- Python 可变对象与不可变对象
- python程序打包成exe方案
- Scikit Source Code Rea 4000 ding(2015.05.31)
- Pool进程池创建大量子进程,进程间通信
- Python高级编程–正则表达式(习题)
- Python基础:10函数参数
- 翻译《Writing Idiomatic Python》(五):类、上下文管理器、生成器
- Python Django 的 django templatedoesnotexist
- Python过滤图片文件
- Python基础:09函数式编程
- 在windows下部署python网站
- Python面试题汇总