python3.1中的特性有哪些
1、千位数格式化,可以在使用字符串格式化函数时直接完成。
在格式化大数时,通常是每三位数放置逗号,使数字更易读(例如,1,048,576比1048576更容易读)。
"2tothe20thpoweris{:,d}".format(2**20)
'2tothe20thpoweris1,048,576'
2、collections.Counter类是collections的一部分。
是Python中的一个秘密超级武器。它经常在Python的面试题的简单解答中首次遇到,但它的价值并不限于此。
hd_song="""
Inwinter,whenthefieldsarewhite,
Isingthissongforyourdelight.
InSpring,whenwoodsaregettinggreen,
I'lltryandtellyouwhatImean.
InSummer,whenthedaysarelong,
Perhapsyou'llunderstandthesong.
InAutumn,whentheleavesarebrown,
Takepenandink,andwriteitdown.
"""
3、执行软件包中的__main__模块。
从Python3.1开始,python-mpackage将执行软件包中的__main__模块。这是一个放调试脚本或命令的好地方,这些脚本主要是用工具执行的,不需要很短。
以上就是Python3.1中的特性,希望对大家有所帮助。更多Python学习教程请关注IT培训机构:千锋教育。