標籤:int put 一起 err list erro 空格 進位 learn
參考書目:《Learn Python The Hard Way》
##練習10print("i am 6‘2\"tall.")#將雙引號轉義print(‘i am 6\‘2"tall.‘)#將單引號轉義#列印出來的就是引號裡的字串,這個例子就是為了說明引號裡出現同種引號怎麼辦tabby_cat="\ti‘m tabbled in." #\t空格(橫向)persian_cat="i‘m split\non a line" #\n 新行backslash_cat="i‘m \\a\\ cat" #\\ 一個\fat_cat=‘‘‘i‘ll do a list:\t* Cat food\t* Fishies\t* Cathlp\n\t* Grass‘‘‘print(tabby_cat)print(persian_cat)print(backslash_cat)print(fat_cat)# 逸出字元 描述# \(在行尾時) 續行符# \\ 反斜線符號# \‘ 單引號# \" 雙引號# \a 響鈴# \b 退格(Backspace)# \e 轉義# \000 空# \n 換行# \v 縱向定位字元# \t 橫向定位字元# \r 斷行符號# \f 換頁# \oyy 八位元,yy代表的字元,例如:\o12代表換行# \xyy 十六進位數,yy代表的字元,例如:\x0a代表換行# \other 其它的字元以普通格式輸出weather="ranning"print("\t*today is %s"%weather) #格式化字元和逸出序列放在一起## 練習11print("How old are you?")age=input()print("How tall are you?")height=input()print("How much do you weigh?")weight=input()print("So,you‘re %s old,%s tall and %s heavy."%(age,height,weight))#python3裡將沒有raw_input,只有input()#input()它希望能夠讀取一個合法的 python 運算式,即你輸入字串的時候必須使用引號將它括起來,否則它會引發一個 SyntaxError#input()就是讓你輸入啦#最後一個print把%s換成%r的話,年齡、體重、身高會加上引號#把三個input()改成input("age:"),input("height:"),input("weight:")##練習12age=input("How old are you?")height=input("How tall are you?")weight=input("How much do you weigh?")print("So,you‘re %s old,%s tall and %s heavy."%(age,height,weight))22#跟練習11一個意思,但是更加簡練
4.28-python學習筆記(轉義符&input函數)