网络
物理层
数据链路层
网络层
传输层
应用层
def binary_search(lis,item):
low = 0
high = len(lis)-1
if low <= high:
mid = (low+high)/2
if lis[mid]<item:
low = mid+1
elif lis[mid]>item:
high = mid -1
else:
return mid
return None
mylist = [1,3,5,7]
print(binary_search(mylist,3))
def bubble_sort(mylist):
for i in range(0,len(mylist)):
for j in range(0,len(mylist)-1):
if mylist[j] > mylist[j+1]:
mylist[j],mylist[j+1] = mylist[j+1],mylist[j]
return mylist
a=[1,77,23,2]
print bubble_sort(a)
def quick_sort(mylist):
if len(mylist)<2:
return mylist
else:
privot=mylist[0]
less = [i for i in mylist[1:] if i<privot]
greater = [i for i in mylist[1:] if i>privot]
return quick_sort(less)+[privot]+quick_sort(greater)
print quick_sort([34,31,22,1])
单例:
#test.py
class my_singleton(object):
def test(self):
pass
singleton = my_singleton()
#to use
from test import singleton
singleton.test()
a = "abcd"
print a[::-1]
print ‘‘.join(a[i] for i in range(len(a)-1,-1,-1))
microcode_ctl Intel系列的CPU可以通过这个服务支持额外的微指令集
http://blog.sina.com.cn/s/blog_1554fae900102xfmn.html