忏悔啊,就写了一个类还出了 bug⋯⋯
写了单元测试还出了 bug⋯⋯
type(data) == type("") 这种办法是不行的,因为 "" 是 str 类型,如果 data 是 unicode 的话这种判断就不成立了,而应该采用这种办法:isinstance(data, basestring),其中 basestring 是 str 和 unicode 两个类的父类。
type(data) == type("")
isinstance(data, basestring)
期待 python 3k⋯⋯
Your email address will not be published. Required fields are marked *
Name *
Email *
Website
Comment
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">
Notify me of followup comments via e-mail