2019-01-07
上周在对于从网址中解析出来的字段进行直接print打印操作的时候回抛出异常
一番乱查发现是编码的问题
当时进行转换就直接解决了
2019年1月7日12:12:59
现在回头查找具体问题所在和解决方案和具体的相关 知识
菜鸟的encode
菜鸟的decode
首先要搞清楚,python内部字符串的编码方式是unicode 就是以前说的优内code字符集 我们处理时往往以unicode作为中间编码方式进行转换
新学到一个指令,就是xxx.class 输出一个变量的属性
>>> print b
{}
>>> print b.__class__
<type 'dict'>
>>> c = []
>>> print c
[]
>>> print c.__class__
<type 'list'>
>>> d=c.set()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'set'
>>> d=set(c)
>>> print d
set([])
>>> print d.__class__
<type 'set'>
>>>
KeyboardInterrupt
网友评论