进击的python-第四集

花絮:

Tornado框架和服务器一起组成一个WSGI的全栈替代品,一般为了性能两个一起使用。异步非阻塞的设计方式。ternado就是提升单台服务器的性能。

c10k:并发一万



python的函数:

def menu():
'this is test'
print('*'*20)
print('this is menu')
print('*'*20)
menu()
print(menu.__doc__)

选择语句

看以什么结尾,主要选择语句的:

a='hello'
if a.endswith('h'):
print('以h结尾')
elif a.endswith('e'):
print('以e结尾')
else:
print('以o结尾')

循环打印出1-100

i=1
while i< 100:
print(i)
i+=1

for循环遍历(迭代) 更显得代码紧凑,相比于while循环更加好用

list=[1,2,3,4,5]
for i in list:
print(i)

range内置函数产生序列

list_2=range(1,100)
for m in list_2:
print(m)

使用dir查看python的数据结构: