life is short, you need python
2017-08-07 15:39
435 查看
人事苦短,我用python。
这句话应该大部分都听过吧,意思就是体现了Python的简洁、明了。
没代码说个xx:
多线程:
>>> for thread in [ready, aim, fire]: >>> ... thread.start()
Fibonacci序列:
fib = lambda n: n if n < 2 else fib(n-1) + fib(n-2)
从list获取元素:
>>>alist = ['foo', 'foo', 'hello', 'hello', 'hello', 'bar'] >>>print list(set(alist))
unique特性:
x = [1,5,3,2] y = x y.sort() print x print y Output: [1,2,3,5] [1,2,3,5]
交换两个变量:
a,b = b,a
串联两个字典:
>>> dict_1 = {1: 'a', 2: 'b', 3: 'c'} >>> dict_2 = {4: 'd', 5: 'e', 6: 'f'} >>> dict_1 {1: 'a', 2: 'b', 3: 'c'} >>> dict_2 {4: 'd', 5: 'e', 6: 'f'} >>> dict_1.update(dict_2) >>> dict_2 {4: 'd', 5: 'e', 6: 'f'} >>> dict_1 {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f'}
相关文章推荐
- Life is short, You need Python
- SE复习日记【三】Life is short, you need Python
- Life is short, you need Python
- life is short, you need python
- life is short, you need python
- Life is short, you need Python
- Life is short,you need python!|(2)
- Life is short,you need python!|(3)
- Life is too short, Use python?
- Life is short,you need python!|(4)
- [python] Lift is short, I need python!
- Life is short,you need python!(1)
- python bs4解析网页时 bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to inst
- The ‘InnoDB’ feature is disabled; you need MySQL built with ‘InnoDB’ to have it working
- 在Linux中编译文件时出现:Your intltool is too old. You need intltool 0.35.0 or later
- What is LineageOS ? Everything you need to know about Lineage OS
- Attention is all you need 论文记录
- Attention is all you need阅读笔记
- 在Linux中编译文件时出现:Your intltool is too old. You need intltool 0.35.0 or later
- 【论文阅读】Attention Is All You Need