iT邦幫忙

2025 iThome 鐵人賽

0
自我挑戰組

Python 函式大全系列 第 47

Python 模組概說 《 pprint 模組 》

  • 分享至 

  • xImage
  •  

✦ 功能:格式化輸出複雜的資料結構 (如:巢狀字典、列表、集合等),透過縮排和分行來改善可讀性使其更易於閱讀和理解

✦ 屬性與方法 :

pprint.pprint()

說明:輸出格式化後的物件,並加以換行
https://ithelp.ithome.com.tw/upload/images/20251020/20177993qPfAc0DzKO.jpg

pprint.pformat()

說明:非直接印出,而是回傳字串,可進一步處理或記錄

pprint.isreadable(object)

說明:判定 object 的格式化輸出是否可被 eval() 還原

pprint.isrecursive(object)

說明:判定是否為需遞迴表示 (recursive) 的物件結構(例如 list 引用自己)

https://ithelp.ithome.com.tw/upload/images/20251020/20177993CoohhLfoSh.jpg


上一篇
Python 模組概說 《 pickle 模組 》
下一篇
Python 模組概說 《 queue 模組 》
系列文
Python 函式大全50
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言