python学习(常用技巧)
来源:互联网 发布:目前那个网络云盘好用 编辑:程序博客网 时间:2024/06/06 02:22
技巧:利用切片对象翻转队列
foolist = [ 1, 2, 3]
foolist[::-1]
[3, 2, 1]
技巧:巧用None做切片对象的stop索引值,可以打印整个列表。
list_str = "abcde"
for i in [None] + range(-1, -len(list_str), -1):
print list_str[:i]
技巧:交换变量的值
x, y = y, x
技巧:合并多重队列
a = [[1, 2], [3, 4], [5, 6]]
import itertools
list(itertools.chain.from_iterable(a))
技巧:字典排序
num_value = {13600000001:1000, 13600000020:200, 13500000001:2000}
安装value的升序排序:
sorted(num_value.iteritems(), key = lambda ad:ad[1])
安装key的升序排序:
sorted(num_value.iteritems(), key = lambda ad:ad[0])
0 0
- python学习(常用技巧)
- python学习笔记-常用技巧整理
- Python爬虫学习之常用技巧详解
- 机器学习-->python常用可视化技巧
- Python常用技巧(更新ing)
- python常用技巧
- python 常用小技巧
- python常用技巧
- python 常用技巧
- Python 常用技巧(待续)
- Python pandas 常用技巧
- Python 常用技巧
- python常用可视化技巧
- javascript学习常用技巧
- python之常用语法技巧
- Python 中一些常用技巧
- Python常用的爬虫技巧
- python技巧32[常用技巧集]
- Servlet生命周期与工作原理
- hdu 1014 Uniform Generator
- 初学JZ2440之编译最小根文件系统(上)
- 取物游戏的必胜策略
- IOS 开发 手势 及事件传递机理
- python学习(常用技巧)
- word07 插入目录以及遇到的问题解决
- poj 1740 A New Stone Game(博弈)
- 5.有时候学习新东西会有种很好的感觉
- 为什么 ++[[]][+[]]+[+[]] = 10 ?
- 中国古典十大悲剧
- android操作word
- visual studio 2010 旗舰版 重装问题
- 振作只需一个理由:日子不能这样过