国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

Python內(nèi)置函數(shù)locals

來源:懂視網(wǎng) 責(zé)編:小采 時間:2020-11-27 14:28:04
文檔

Python內(nèi)置函數(shù)locals

Python內(nèi)置函數(shù)locals:英文文檔:locals()Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in
推薦度:
導(dǎo)讀Python內(nèi)置函數(shù)locals:英文文檔:locals()Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in

英文文檔:

locals()

Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in class blocks.

說明:

  1. 函數(shù)功能返回當(dāng)前作用域內(nèi)的局部變量和其值組成的字典,與globals函數(shù)類似(返回全局變量)

>>> locals()
{'__package__': None, '__loader__': , '__doc__': None, '__name__': '__main__', '__builtins__': , '__spec__': None}

>>> a = 1

>>> locals() # 多了一個key為a值為1的項(xiàng)
{'__package__': None, '__loader__': , 'a': 1, '__doc__': None, '__name__': '__main__', '__builtins__': , '__spec__': None}

  2. 可用于函數(shù)內(nèi)。

>>> def f():
 print('before define a ')
 print(locals()) #作用域內(nèi)無變量
 a = 1
 print('after define a')
 print(locals()) #作用域內(nèi)有一個a變量,值為1

 
>>> f

>>> f()
before define a 
{} 
after define a
{'a': 1}

 3. 返回的字典集合不能修改。

>>> def f():
 print('before define a ')
 print(locals()) # 作用域內(nèi)無變量
 a = 1
 print('after define a')
 print(locals()) # 作用域內(nèi)有一個a變量,值為1
 b = locals()
 print('b["a"]: ',b['a']) 
 b['a'] = 2 # 修改b['a']值
 print('change locals value')
 print('b["a"]: ',b['a'])
 print('a is ',a) # a的值未變

 
>>> f()
before define a 
{}
after define a
{'a': 1}
b["a"]: 1
change locals value
b["a"]: 2
a is 1
>>>

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

Python內(nèi)置函數(shù)locals

Python內(nèi)置函數(shù)locals:英文文檔:locals()Update and return a dictionary representing the current local symbol table. Free variables are returned by locals() when it is called in function blocks, but not in
推薦度:
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 精品一区二区三 | 欧美爱爱图| 日韩福利在线 | 亚洲国产欧美91 | 国产伊人久久 | 91精品国产91久久久久久 | 久久久一区二区三区 | 久久er | 国产精品久久精品 | 久久精品男人影院 | 一区二区三区在线视频播放 | 欧美另类图片亚洲偷 | 久久精品无遮挡一级毛片 | 久久国产香蕉视频 | 婷婷成人亚洲 | 精品一区二区三区三区 | 日韩三 | 亚洲精品成人久久久影院 | 在线h片 | 在线免费观看亚洲视频 | 欧美精品日韩 | 亚洲视频二| 看毛片的网站 | 欧美精品一区二区三区在线 | 毛片一区 | 精品日韩在线 | 亚洲欧美日韩高清一区二区三区 | 国产国拍亚洲精品永久不卡 | 久久se精品一区二区国产 | 亚洲第一视频 | 欧美福利在线观看 | 国产毛片久久久久久国产毛片 | 欧美精品一区二区三区免费 | 国产淫视 | 亚洲欧美日韩天堂 | 91精品国产免费久久久久久 | 国产区在线看 | 中文字幕va一区二区三区 | 久久夜色精品国产亚洲 | 国产成人精品.一二区 | 91久久国产口精品久久久久 |