Python3.1中的特性有哪些

2025-12-01 0 56,478

1、千位数格式化,可以在使用字符串格式化函数时直接完成。

在格式化大数时,通常是每三位数放置逗号,使数字更易读(例如,1,048,576 比 1048576 更容易读)。

"2 to the 20th power is {:,d}".format(2**20)
'2 to the 20th power is 1,048,576'

2、collections.Counter类是collections的一部分。

是 Python 中的一个秘密超级武器。它经常在 Python 的面试题的简单解答中首次遇到,但它的价值并不限于此。

hd_song = """
In winter, when the fields are white,
I sing this song for your delight.
 
In Spring, when woods are getting green,
I'll try and tell you what I mean.
 
In Summer, when the days are long,
Perhaps you'll understand the song.
 
In Autumn, when the leaves are brown,
Take pen and ink, and write it down.
"""

3、执行软件包中的 __main__ 模块。

从 Python 3.1 开始,python -m package 将执行软件包中的 __main__ 模块。这是一个放调试脚本或命令的好地方,这些脚本主要是用工具执行的,不需要很短。

以上就是Python3.1中的特性,希望对大家有所帮助。更多Python学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.1,DELL G3电脑。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:以上部本文内容由互联网用户自发贡献,本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。投诉邮箱:3758217903@qq.com

ZhiUp资源网 python基础 Python3.1中的特性有哪些 https://www.zhiup.top/1320.html

相关