#-*-coding:cp936-*-#python#Xiaodeng#Common uses of Python's module PprintImportPprintdata= [(1,{'a':'A','b':'B','C':'C','D':'D'}), (2,{'e':'E','F':'F','g':'G','h':'H','I':'I','J':'J','k':'K','L':'L'}),]Print '--'*30#1. Printing effectpprint.pprint (data)" "------------------------------------------------------------[(1, {' A ': ' A ', ' B ': ' B ', ' C ': ' C ', ' d ': ' d '}), (2, {' E ') : ' E ', ' F ': ' f ', ' G ': ' G ', ' H ': ' H ', ' I ': ' I ', ' J ': ' J ', ' K ': ' K ', ' l ': ' l '}]" "#2. Formattingdata = [(1,{'a':'A','b':'B','C':'C','D':'D'}), (2,{'e':'E','F':'F','g':'G','h':'H','I':'I','J':'J','k':'K','L':'L'}),]result=Pprint.pformat (data) forKeyinchresult.splitlines ():PrintKey" "[(1, {' A ': ') A ', ' B ': ' B ', ' C ': ' C ', ' d ': ' d '}, (2, {' E ': ' E ', ' F ': ' f ', ' G ': ' G ', ' H ': ' H ', ' I ': ' I ', ' J ': ' J ', ' K ': ' K ', ' l ': ' l '}]" "
Common uses of Python's module pprint