python基础--字符串编码格式转化
#! /usr/bin/env python# -*- coding: utf-8 -*-dd = u"野草"print type(dd)#Unicode转化为strdd = dd.encode("utf-8")print type(dd)#str转化为Unicodedd = dd.decode("gbk")print type(dd)
·
#! /usr/bin/env python
# -*- coding: utf-8 -*-
dd = u"野草"
print type(dd)
#Unicode转化为str
dd = dd.encode("utf-8")
print type(dd)
#str转化为Unicode
dd = dd.decode("gbk")
print type(dd)
更多推荐
已为社区贡献16条内容
所有评论(0)