摘要: 思路是把字典转为列表后再排序d={'z':1,'y':2,'x':3} # 字典s=d.items() # [('y', 2), ('x', 3), ('z', 1)] 列表s.sort() # [('x', 3), ('y', 2), ('z', 1)] 排序列表# 或者连起来写(sort是... 阅读全文
posted @ 2014-09-30 11:37 ibg 阅读(246) 评论(0) 推荐(0) 编辑
摘要: string类型是不可变的,因此不能采用直接赋值的方式。比如一个字符串 helloworld,想把o替换成z,那么只有先替换,然后再迭代。strings="helloworld"hello=strings.replace('o','z')for index,string in enumerate(h... 阅读全文
posted @ 2014-09-30 11:31 ibg 阅读(343) 评论(0) 推荐(0) 编辑