Equivalent of python's ord(), chr() in go?

前端 未结 2 1541
甜味超标
甜味超标 2020-12-11 15:11

What is the equivalent of python\'s chr() and ord() functions in golang?

chr(97) = \'a\'
ord(\'a\') = 97
2条回答
  •  我在风中等你
    2020-12-11 15:49

    It appears that a simple uint8('a') will produce a correct output. To convert from integer to string string(98) will suffice:

    uint8('g') // 103
    string(112) // p
    

提交回复
热议问题