新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python ChainMap標準庫的跟蹤使用
1、在與ChainMap起源密切相關(guān)的性能問題中,ConfigParser是其生活中的標準庫模塊。

可以在模塊中找到ChainMap作為一部分。這種方法使用字符串模板作為參數(shù),并且允許在PEP292中替換字符串。輸入字符串模板包含嵌入標識符,您可以在以后用實際值替換:Templatestring。
>>> import string
>>> greeting = "Hey $name, welcome to $place!"
>>> template = string.Template(greeting)
>>> template.substitute({"name": "Jane", "place": "the World"})
'Hey Jane, welcome to the World!'2、substitute()替換place提供的關(guān)鍵字參數(shù)值,而非輸入字典中的值。
用于ChainMap在名稱沖突時有效地管理輸入值的優(yōu)先級。
>>> import string
>>> greeting = "Hey $name, welcome to $place!"
>>> template = string.Template(greeting)
>>> template.substitute(
... {"name": "Jane", "place": "the World"},
... place="Real python"
... )
'Hey Jane, welcome to Real Python!'以上就是python ChainMap標準庫的跟蹤使用,希望對大家有所幫助。更多Python學習指路:創(chuàng)新互聯(lián)python教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
網(wǎng)頁標題:創(chuàng)新互聯(lián)Python教程:python ChainMap標準庫的跟蹤使用
鏈接分享:http://fisionsoft.com.cn/article/cdsjged.html


咨詢
建站咨詢
