變量的作用:
Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
變量用于存儲(chǔ)計(jì)算機(jī)程序中引用和操作的信息。它們還提供了用描述性名稱標(biāo)記數(shù)據(jù)的方法,因此讀者和我們自己可以更清楚地理解我們的程序。將變量看作容器來保存信息是很有幫助的。他們唯一的目的是在內(nèi)存中標(biāo)記和存儲(chǔ)數(shù)據(jù)。這些數(shù)據(jù)可以在整個(gè)程序中使用。
變量定義規(guī)則:
變量名只能是 字母、數(shù)字或下劃線的任意組合
變量名的第一個(gè)字符不能是數(shù)字
以下關(guān)鍵字不能聲明為變量名['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']
模塊名,包名 :小寫字母, 單詞之間用_分割。
類名:首字母大寫。
全局變量: 大寫字母, 單詞之間用_分割。
普通變量: 小寫字母, 單詞之間用_分割。
函數(shù): 小寫字母, 單詞之間用_分割。
實(shí)例變量: 以_開頭,其他和普通變量一樣 。
私有實(shí)例變量(外部訪問會(huì)報(bào)錯(cuò)): 以__開頭(2個(gè)下劃線),其他和普通變量一樣 。
專有變量: __開頭,__結(jié)尾,一般為python的自有變量(不要以這種變量命名)。
當(dāng)前題目:python變量的作用與定義規(guī)則
分享鏈接:http://m.kartarina.com/article40/jedoho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、標(biāo)簽優(yōu)化、自適應(yīng)網(wǎng)站、品牌網(wǎng)站設(shè)計(jì)、虛擬主機(jī)、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)