github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/format_int.en.md (about)

     1  ### `format_int()` {#fn-format-int}
     2  
     3  Function prototype: `fn format_int(val: int, base: int) str`
     4  
     5  Function description: Converts a numeric value to a numeric string in the specified base.
     6  
     7  Function parameters:
     8  
     9  - `val`: The number to be converted.
    10  - `base`: Base, ranging from 2 to 36; when the base is greater than 10, lowercase letters a to z are used to represent values 10 and later.
    11  
    12  Example:
    13  
    14  ```python
    15  # script0
    16  a = 7665324064912355185
    17  b = format_int(a, 16)
    18  if b != "6a60b39fd95aaf71" {
    19      add_key(abc, b)
    20  } else {
    21      add_key(abc, "ok")
    22  }
    23  
    24  # result
    25  '''
    26  {
    27      "abc": "ok"
    28  }
    29  '''
    30  
    31  # script1
    32  a = "7665324064912355185"
    33  b = format_int(parse_int(a, 10), 16)
    34  if b != "6a60b39fd95aaf71" {
    35      add_key(abc, b)
    36  } else {
    37      add_key(abc, "ok")
    38  }
    39  
    40  # result
    41  '''
    42  {
    43      "abc": "ok"
    44  }
    45  '''
    46  ```