有几种方法可以做到这一点。首先,您可以创建一个字典并将字母指定为数字。另一种方法是找到 chr() 代码编号,然后使用随机数生成器来选择字符编号。这是我推荐的。# importsimport random# pick a random number between the ord of 'a' and the ord of 'z' Google these for # more infopick = random.randint(ord('a'), ord('z'))# print the char of the ord of the random number pickedprint(chr(pick))