==等号判断运算符使用失效

1233阅读 0评论2012-09-12 wdove
分类:Python/Ruby

E.g:
soc_id = soc_type[2:]

       if soc_id in [61, 63]:
            print soc_id

soc_id将不会被打印,这是因为soc_id是string, 必须先使用int(soc_id)才行。
这里的教训是python中虽然没有类型声明,但变量类型在第一次赋值时已经确定了。

上一篇:Error of "No module named xxx"
下一篇:在python中使用*, ?通用匹配符