ITeye博客

可爱的python

8366 · 2010-11-08 19:28 · Python · 编程语言 · Markdown

1. ipython 是一个python的交互式的shell,功能强大,支持语法高亮,自动完成,代码调试,对象自省,支持bash shell

命令

 

2. python 没有switch 语句

 

3. python 中的三元表达试: 工作中的例子:getattr(o, "addresses", "") 这个可能返回空 {}

 

ip = getattr(o, "addresses", "").get('private')[0]['addr'] if(getattr(o, "addresses", "")) else 'None'

 

4. 字符转换成整型 

 

>>> a="12345"
>>> import string
>>> string.atoi(a)

 

    整形转化成字符  extAttrs['size'] = "%s" % volume[3]   ,把整形 值volume[3] 转化成字符

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。