Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想编写一个程序,将 0 变为 A,将 1 变为 B,将 2 变为 C,依此类推,我试过这样做:
def problem(number): return chr(number) - chr(0)
但无论我的输入是什么,我总是得到 A。
import string def problem(number): if number > len(string.ascii_uppercase): return None return string.ascii_uppercase[number]