<abbr id="ciwa6"><option id="ciwa6"></option></abbr>
  • <sup id="ciwa6"><kbd id="ciwa6"></kbd></sup>
    <small id="ciwa6"></small>
  • 千鋒教育-做有情懷、有良心、有品質(zhì)的職業(yè)教育機構(gòu)

    400-811-9990
    手機站
    千鋒教育

    千鋒學習站 | 隨時隨地免費學

    千鋒教育

    掃一掃進入千鋒手機站

    領(lǐng)取全套視頻
    千鋒教育

    關(guān)注千鋒學習站小程序
    隨時隨地免費學習課程

    上海
    • 北京
    • 鄭州
    • 武漢
    • 成都
    • 西安
    • 沈陽
    • 廣州
    • 南京
    • 深圳
    • 大連
    • 青島
    • 杭州
    • 重慶
    當前位置:成都千鋒IT培訓  >  技術(shù)干貨  >  python如何使用round函數(shù)

    python如何使用round函數(shù)

    來源:千鋒教育
    發(fā)布人:xqq
    時間: 2023-11-07 15:29:39

    在python3中,round(1.0/2.0)得到的是1,而在python2中,round(1.0/2.0)得到的是0

    $python

    Python2.7.8(default,Jun182015,18:54:19)

    [GCC4.9.1]onlinux2

    Type"help","copyright","credits"or"license"formoreinformation.

    >>>round(0.5)

    1.0

    $python3

    Python3.4.3(default,Oct142015,20:28:29)

    [GCC4.8.4]onlinux

    Type"help","copyright","credits"or"license"formoreinformation.

    >>>round(0.5)

    0

    使用的一般語法是round(number,digits)

    number,要四舍五入的數(shù),digits是要小數(shù)點后保留的位數(shù)

    如果digits大于0,則四舍五入到指定的小數(shù)位。

    如果digits等于0,則四舍五入到最接近的整數(shù)。

    如果digits小于0,則在小數(shù)點左側(cè)進行四舍五入。

    如果round函數(shù)只有參數(shù)number,等同于digits等于0。

    以上內(nèi)容為大家介紹了python培訓之如何使用round函數(shù),希望對大家有所幫助,如果想要了解更多Python相關(guān)知識,請關(guān)注IT培訓機構(gòu):千鋒教育。

    聲明:本站稿件版權(quán)均屬千鋒教育所有,未經(jīng)許可不得擅自轉(zhuǎn)載。

    猜你喜歡LIKE

    python delattr函數(shù)如何使用?

    2023-11-10

    python time.strptime的格式化

    2023-11-10

    pythonGIL在Python多線程的應用

    2023-11-10

    最新文章NEW

    python中pdb模塊怎么用?

    2023-11-10

    Python如何截圖保存?

    2023-11-10

    python?中缺少module怎么辦?

    2023-11-10

    相關(guān)推薦HOT

    更多>>

    快速通道 更多>>

    最新開班信息 更多>>

    網(wǎng)友熱搜 更多>>