比如原始的List变量的值是这种: [{"]}] 而想要将其输出为带缩进的,树状的,很漂亮的效果,那么可以通过这样的方法: import json #demoDictList is the value we want format to output jsonDumpsIndentStr = json.dumps(demoDictList, indent=1) print "jsonDumpsIndentStr=",jsonDumpsIndentStr 输出: [ { &qu
字典推导: x = ['A', 'B', 'C', 'D'] y = ['Alice', 'Bob', 'Cecil', 'David'] print({i:j for i,j in zip(x,y)}) >>>{'A': 'Alice', 'B': 'Bob', 'C': 'Cecil', 'D': 'David'} 列表推导: m=[x*x for x in range(0,10)] print(m) >>> [0,1,4,9,16,25,36,49,64,81]