Updated at: June 28, 2017
python2 is not compatible with python3 .
most of linux distributions includle python defaultly.
$ python -V
Python 2.7.6
$ python3 -V
Python 3.4.0
personally, l like to add a alias to use python3 as default.
alias python='python3'
pip, python package manager. like gem for ruby, npm for nodejs, maven for java
$ sudo apt-get -y install python-pip
ipython, python interactive terminal, like irb for ruby.
$ pip install ipython
wiki:python3 doc
branch
if condition1:
exec1
elif condition2:
exec2
else:
exec3
loop
for var in list/tuple:
exec
while condition:
exec
collection
和list比较,dict有以下几个特点:查找和插入的速度极快,不会随着key的增加而变慢;需要占用大量的内存,内存浪费多。 而list相反:查找和插入的时间随着元素的增加而增加;占用空间小,浪费内存很少。
function
def my_func(x):
//do something