python中使用字典内置方法get应用:
dict = {‘1’:’first’,’2’:’second’,’3’:third’};
number = raw_input(“input your number:”)
print dict.get(number,’error’) //dict[‘key’]
python中threading的使用:
import threading
import time
def movie(counter):
while counter:
time.sleep(1)
print “playing movie”
counter -= 1
def music(counter):
while counter:
time.sleep(1)
print “playing music”
counter -= 1
def main():
thread1 = threading.Thread(target = movie, args = (5, ))
thread2 = threading.Thread(target = music, args = (5, ))
thread1.start()
thread2.start()
print “main thread”
if __name__ == "main":
main()