python中杂乱问题
1 字符串格式化中的格式指定
format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type] fill ::= <any character> align ::= "<" | ">" | "=" | "^" sign ::= "+" | "-" | " " width ::= integer precision ::= integer type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"
详细信息请转官网
2 查看字符的各种编码方法使用repr
In [3]: a=u"啊" In [4]: repr(a) Out[4]: "u'\\u554a'" In [5]: b = a.encode("utf-8") In [6]: repr(b) Out[6]: "'\\xe5\\x95\\x8a'" In [7]: c = a.encode("gbk") In [8]: repr(c) Out[8]: "'\\xb0\\xa1'"
学习过程中,难免出错。如果您在阅读过程中遇到不太明白,或者有疑问。欢迎指正...联系邮箱crazyCodeLove@163.com
如果觉得有用,想赞助一下请移步赞助页面:赞助一下