>>> p =[[['red','yellow'],['pink']],['black'],'blue']>>> pprint.pprint(p, width=5)[[['red','yellow'],['pink']],['black'],'blue']>>>
textwrap用來格式化段落
>>>import textwrap as tw
>>> doc =''' she is so gorgeous! I really like her !
... May the distance between her want and I am weak .
... Try Hard... Learning your all time... aseert...'''>>>print(tw.fill(doc, width=40))# 每行40個字母she is so gorgeous! I really like her !
May the distance between her want and I
am weak . Try Hard... Learning
your all time... aseert...>>>
T = Template('${k}like $kk')
T.substitute(k='', kk='')>>>from string import Template # 導入摸板>>> t = Template('${she} is so $how')# $加標識符表示占位>>> t.substitute(she='she', how='adorable')# 把占位符給替換了'she is so adorable'>>># 如果,參數不完整>>> t = Template('return the $item to $owner')>>> t.substitute(dict(item='unladen swallow'))# 未提供 owner的參數Traceback (most recent call last):File "<stdin>", line 1,in<module>File "D:\softWare\python\python3.7\lib\string.py", line 132,in substitutereturn self.pattern.sub(convert, self.template)File "D:\softWare\python\python3.7\lib\string.py", line 125,in convertreturnstr(mapping[named])KeyError:'owner'>>># 用戶也可能出現上面滴參數不完整情況 用safe_substitute>>> t.safe_substitute(dict(item='unladen swallow'))'return the unladen swallow to $owner'>>>
>>> Decimal('1.00')% Decimal('0.10')Decimal('0.00')>>>>>>1.00%0.100.09999999999999995>>>>>>sum([Decimal('0.1')*10])== Decimal('1.0')True>>> s =sum([0.1]*10)>>> s0.9999999999999999>>> s ==1.0False