# -*- coding: utf-8 -*-
import _thread
from time import sleep, ctime
def fun1():
sleep(2)
print('aaaaaaaaaa')
def fun2():
sleep(1)
print('bbbbbbbbb')
def main():
_thread.start_new_thread(fun1,())
_thread.start_new_thread(fun2,())
sleep(5)
print('end')
main()
#------------带参数-------------------------
# -*- coding: utf-8 -*-
import _thread
from time import sleep, ctime
def fun1(page):
sleep(2)
print('aaaaaaaaaa=%i'%page)
def fun2(page):
sleep(1)
print('bbbbbbbbb=%i'%page)
def main():
page=1
_thread.start_new_thread(fun1,(page,))
page=2
_thread.start_new_thread(fun2,(page,))
sleep(5)
print('end')
main()
冒泡
arr = (53, 16, 99, 1, 72, 19, 25, 33, 37)
arr=list(arr)
arrlen = len(arr)
for a in range(arrlen):
for b in range(a + 1, arrlen):
if (arr[a] > arr[b]):
temp = arr[a]
arr[a] = arr[b]
arr[b] = temp
print(arr)