티스토리 뷰

공부

[python] chr(ord('A') + 1) == 'B'

승가비 2023. 4. 28. 13:29
728x90
def add(c, x):
  return chr(ord(c)+x)

https://stackoverflow.com/questions/9739992/python-how-to-generate-char-by-adding-int

 

python: how to generate char by adding int

I can use 'a'+1 to get 'b' in C language, so what the convient way to do this in Python? I can write it like: chr(ord('a')+1) but I don't know whether it is the best way.

stackoverflow.com

 

728x90
댓글