4.28-python學習筆記(轉義符&input函數)

來源:互聯網
上載者:User

標籤: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函數)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.