python筆記2-變數

來源:互聯網
上載者:User

標籤:rom   快速   雙引號   小數   注釋   body   from   單引號   finally   

變數

存東西所用

#定義變數
name=‘feifei‘#定義變數,字串
age=18.9#整型或者小數定義變數不需要加引號
print(name)
print(age)
name2="what‘s your name"#裡面有單引號外面就用雙引號
name3=‘你長得“很帥”‘#裡面是雙引號外面就用單引號
name4=‘‘‘ ‘你長得“很帥”‘ ‘‘‘#裡面既有雙引號又有單引號就用三引號標記
 
#ctrl+/ 快速注釋
#3個單引號還能進行段落的注釋
 

變數的定義規則:

變數名要見名知意,不能瞎寫,瞎寫到後面自己都看不懂那個變數是幹啥的,不要用拼音,那樣很low,更不要用中文當變數名,那是2b程式員乾的事,但是python的確可以用中文當變數名!

變數名只能是 字母、數字或底線的任意組合
變數名的第一個字元不能是數字

以下關鍵字不能聲明為變數名

 [‘and‘, ‘as‘, ‘assert‘, ‘break‘, ‘class‘, ‘continue‘, ‘def‘, ‘del‘, ‘elif‘, ‘else‘, ‘except‘, ‘exec‘, ‘finally‘, 

     ‘for‘, ‘from‘, ‘global‘, ‘if‘, ‘import‘, ‘in‘, ‘is‘, ‘lambda‘, ‘not‘, ‘or‘, ‘pass‘, ‘print‘, ‘raise‘, ‘return‘, 

     ‘try‘, ‘while‘, ‘with‘, ‘yield‘]

python筆記2-變數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.