![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
小鲸鱼219
这个作者很懒,什么都没留下…
展开
-
python dict order by key 字典关键字排序
from operator import itemgetter 通过使用operator模块的itemgetter函数,可以非常容易的排序这样的数据结构 rows = [ {'fname': 'Brian', 'lname': 'Jones', 'uid': 1003}, {'fname': 'David', 'lname': 'Beazley', 'uid': 10转载 2015-05-14 20:49:46 · 3190 阅读 · 0 评论 -
python 字符串插入变量
字符串中插入变量 Python并没有对在字符串中简单替换变量值提供直接的支持。 但是通过使用字符串的 format() 方法来解决这个问题。比如: >>> s = '{name} has {n} messages.' >>> s.format(name='Guido', n=37) 'Guido has 37 messages.' >>> 或者,如果要被替换的变转载 2015-05-14 21:15:57 · 6592 阅读 · 0 评论