原创 【Python】Learn Python the hard way, ex38 列表操作

ten_things = "Apples Oranges Crows Telephone Light Sugar" print "Wait there's not 10 things in that list, let's fix t

原创 【Python】if語句使用規則

Rules for If-Statements Every if-statement must have an else.If this else should never run because it doesn't make se

原创 VB能夠快速解決問題,依然是偉大的工具

       十年之後,碰到了一位業界高手,他負責芯片技術支持,自己有個VB6做的工具,控制MCU配置芯片協議棧,很慷慨的把源碼和開發板一起給我了,今天花了一天時間,熟悉代碼結構,並根據業務需求增加了讀APDU list並自動連續發送,同

原创 【Python】Learn Python the hard way, ex35 通過一個簡單遊戲,練習循環和分支語句

from sys import exit def gold_room(): print "This room is full of gold. How much do you take?" next = raw

原创 【Python】Learn Python the hard way, ex25 函數綜合練習

def break_words(stuff): """This function will break up words for us.""" words = stuff.split(" ") return wor

原创 【Python】Learn Python the hard way, ex33 while循環

i = 0 numbers = [] while i < 6: print "At the top i is %d" % i numbers.append(i) i += 1 print "Numbers

原创 Keil v5.11給STM32燒錄程序記錄

第一次在別人指導下完成STM32 MCU程序燒寫,連夜記錄下,以免下次忘了   1)安裝Keil MDK511   2)安裝ST Link下載器驅動,重啓PC 3)打開Keil v5,加載工程文件 4)load pack(Keil.ST

原创 【Python】Learn Python the hard way, ex20 用函數讀文件readline

from sys import argv script, input_file = argv def print_all(f): print f.read() def rewind(f): f.seek(0)

原创 【Python】Learn Python the hard way, ex21 函數返回值return

def add(a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract(a, b): print "SUBTRACTING %d

原创 【Python】Learn Python the hard way, ex18 def函數

# this one is like your scripts with argv def print_two(*args): arg1, arg2 = args print "arg1: %r ,arg2: %r" %

原创 【Python】Learn Python the hard way, ex16 讀寫文件

# coding:utf-8 #方法1 ''' from sys import argv script, filename = argv print "We're going to erase %r." % filename prin

原创 【Python】Learn Python the hard way, ex19 函數和變量

def cheese_and_crackers(cheese_count, boxes_of_crackers):     print "You have %d cheeses!" % cheese_count     print "Yo

原创 【Python】Learn Python the hard way, ex29 if語句

people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" if people > cats:

原创 【Python】Learn Python the hard way, ex32 for循環

the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3,

原创 【Python】Learn Python the hard way, ex26 修改代碼錯誤

#coding:utf-8#修改後的代碼如下 import ex25 def break_words(stuff): """This function will break up words for us.""" wor