掃二維碼與項目經理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網交流
1、在與ChainMap起源密切相關的性能問題中,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提供的關鍵字參數(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電腦。

我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網交流