《Python核心編程(第2版)》讀書筆記(6)之用列表模擬堆棧(關鍵詞:Python/列表/堆棧/stack.py)

stack = [] def pushit(): stack.append(raw_input('enter new string: ').strip()) def popit(): if len(stack)==0: print 'can not pop from an empty stack!' else: # 用反單引號(`)來代替repr()函數,把字符串的內容用引號括起來顯示,而不是單單
相關文章
相關標籤/搜索