原创 詳細解析字典,learn python the hard way, 笨方法學python
#coding=utf-8 #create a mapping of provinces to suoxie provinces = { 'Guangdong': 'Yue', 'Sichuan': 'Chuan',
原创 字典實戰應用,笨方法學python
#coding=utf-8 #creat a mapping from child to account_name children = { 'Hannibal': 'Des001', 'Shmily': 'Angel
原创 兒歌
拍拍,拍拍手,我們一起拍, 拍拍拍拍拍拍拍,Shmily拍拍手。 拍拍,拍拍手,Jayden拍拍手, 拍拍拍拍拍拍拍,Alba拍拍手。 調子(row your boat) Good morning to you It's nice t
原创 列表的操作,習題38,learn python the hard way.
]``` #coding=utf-8 ten_things = "Apples oranges Crows Telephone Light Sugar" print "Wait there's not 10 things in that
原创 readlines and readline的區別
#coding=utf-8 #open a file new = open('new.txt', 'r') print "The name of the file:%s" % new line = new.readlines() pri
原创 while循環和for循環的比較,習題33,笨方法學python
1)for 循環 和range()函數: def worker_salary(target_salary, increase_per_month): money_all_he_got = [] for each_mont
原创 習題35,36分支與函數,設計和調試,笨方法學python,中文版遊戲
#coding=utf-8 from sys import exit name = raw_input("請爲自己取名>>>>>") def start(): city_list = ['廣州','深圳', '河源']
原创 關鍵詞break, python
x = 4 while True: x += 1 print x if x > 50: break 用在滿足某個條件,需要立刻退出當前循環時(跳出循環),break語句可以用在for循環和while
原创 assert語句,python, 笨辦法學python
my_list = ['Items'] assert len(my_list) >= 1 my_list.pop() assert len(my_list) >= 1 #list.pop()函數用來移除列表的某個元素 #assert,用
原创 class,類的詳解, python, 笨方法學python
#coding=utf-8 class Song(object): def __init__(self, geci): #__init__(每條橫線都是兩個字符) self.geci = geci #將gec
原创 class, 類,方法,python
#coding=utf-8 class Emplyee: '所有員工的類' #類文檔字符串 empCount = 0 #類變量,它的值在這個類所有實例中共享 #訪問類變量的方法是 類名.類變量,這裏就是Empl
原创 list.pop()函數的用法,python
#coding=utf-8 my_list = ['jj', 'ee', 'c'] print "A List:", my_list.pop() #pop()函數用於移除列表中一個元素,默認最後一個元素,並返回該元素的值,所以這裏打印出
原创 習題35,分支和函數,笨方法學python
#coding=utf-8 from sys import exit def gold_room(): print "This room is full of gold. How much do you take?"
原创 python, del[] 用法, 笨方法學python
#coding=utf-8 city = ['GZ', 'SZ', 'HY', 'ZH', 'XX'] def del_function(): print "This is a function to remove an el