• 技术文章 >Python技术 >Python基础教程

    Python3.1中的特性有哪些

    小妮浅浅小妮浅浅2021-08-26 09:51:38原创3360

    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电脑。

    专题推荐:python31中的特性
    品易云
    上一篇:python中in和is的区分 下一篇:python中__new__的重写

    相关文章推荐

    • python字符串的用法总结• python中有哪些比较操作• python中os.path.join()函数是什么• python数据结构堆的介绍• python参数调用的注意点• python有哪些注释的种类• python自定义日志如何实现• python如何使用skimage包提取图像• python os.path.join()函数的使用• python confusion_matrix()是什么• python Pandas读取数据文件的优点

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网