日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

5、python学习之变量

發布時間:2025/6/17 python 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 5、python学习之变量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

變量的定義:為了方便日后調用,存儲程序中的一些中間結果
變量定義的規則:
1、要具有描述性
2、變量名只能是字母、數字、下劃線的任意組合,不可以是空格或特殊字符(!@#¥%*)
3、不能以中文為變量名
4、變量名的第一個字母不能是數字
5、以下關鍵字不能聲明為變量名
['and','as','assert','break','class','continue','def','del','elif','else','except','finally','for','from','global','if','import','in','is','lambda','not','or','pass','print','paise','return','try','while','with','yield']

# python 風格指南: https://zh-google-styleguide.readthedocs.io/en/latest/


舉例:
賦值
>>> x = 3
>>> y = 4
>>> z = x * y
>>> print ("x*y=", z)
x*y= 12
>>> print("z=",z)
z= 12
>>> print (3*4*5*6/2)
180.0
多次賦值
>>> a = 1
>>> b = a
>>> print(a)
1
>>> print(b)
1
>>> a = 2
>>> print(a)
2
>>> print(b)
1
刪除變量-1
>>> abc = 21
>>> print(abc)
21
>>> del abc
>>> print(abc)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'abc' is not defined
刪除變量-2
>>> abc = 21
>>> print(abc)
21
>>> abc = 25
>>> print(abc)
25 (python內部會進行清理)
note:
1、python不區分變量和常量(使用全部大寫代表常量,常量:不變的量,pie 3.1415926)
2、引號內的值為字符串,沒有引號的值為變量名

?

?

# python 風格指南: https://zh-google-styleguide.readthedocs.io/en/latest/

from keyword import kwlist
for i in kwlist:
print(i)

# False
# None
# True
# and
# as
# assert
# async
# await
# break
# class
# continue
# def
# del
# elif
# else
# except
# finally
# for
# from
# global
# if
# import
# in
# is
# lambda
# nonlocal
# not
# or
# pass
# raise
# return
# try
# while
# with
# yield

?

轉載于:https://www.cnblogs.com/hlc-123/p/10915011.html

總結

以上是生活随笔為你收集整理的5、python学习之变量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。