[原創][連載]nim與python的異同2

overload(方法重載)

  • pythonpython

    不支持
  • nimc++

    支持.和c++相似

基本類型轉換

整數 → 文字列

  1. 使用整數(int/int8/int16/int32/64/uint/uint8/uint16/uint32/uint32)內置方法(由system引入)ui

    let value:int64 = 99999
    echo 「this value is: $#」% $value
    result:
    this value is: 99999
  2. 使用strformat進行格式化(由strformat引入&操做符)this

    let value:int64 = 99999
    echo 「this value is: $#」% &」{value<:可選格式文字列>}」
    • 沒有格式文字列:
      this value is: 99999
    • 共10位,小數位2位,右對齊進行格式化echo 「this value is: $#」% &」{value:>10.2}」result:this value is: 0099999.00
相關文章
相關標籤/搜索