詞匯表 = { 'docstring': '它是檔案字串的一個縮寫。 '標題': '它只是標題的形式。'}
Print(' glossary')
uj5u.com熱心網友回復:
使用pprint庫,正如@don't talk just code所說。
它使串列、字典更易讀
。import pprint
glossary = { 'docstring': 'it is a short form of documentation string.' , 'title': 'it is form of just heading.'}。
pprint.pprint( glossary)
輸出
{'docstring': 'it is a short form of documentation string.' ,
'title'。'it is form of just heading.'}。
如果你不想使用一個庫,你可以使用str.replace。
glossary = { 'docstring': 'it is a short form of documentation string.' , 'title': '它是標題的形式。}
print( str( glossary).replace(", ", " 。
") )
這使得字典成為一個字串,并將每一個逗號,替換為一個新行的逗號。
.
這可能有很多限制
。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/307304.html
標籤:
