基本语法
- 布尔类型:0、空字符串、None默认是False,其他为True。
- 动态语言,任何数据类型都可以赋值给变量。
- 字符串:”或者”“都可以表示;可以用转意字符\,为了避免都用转意字符,诞生了raw字符串,用关键字r;如果要表示多行,可以使用转意字符\n或者使用”’…”’。
- 可以使用关键字u表示unicode的字符编码。
数据类型
list[]:
items is changeable.
append(item)\insert(index,item)\pop().
slip:[start,end,step]
generate:[x+y for x in Collection for y in Collection if condition]
tuple():
items isn’t changeable.
set([]):
cannot repeat.
remove(item)\add(item)
dist{}:
key-value.
values()\itervalues()\items()
range(start,end-1,step)
len(Collection)
enumerate()
isintance(x,str)
if:
if condition:
do something
elif condition:
do something
else:
do others
loop:
for x,y in iterate:
do something
function:
def name(*args):
#*args is changeable args,it is tuple
do something
return x,y
#can return multi args