例:

import random

def getAn(answer):
    if answer == 1:
        return 'one'
    elif answer == 2:
        return 'tow'
    elif answer == 3:
        return 'three'
    elif answer == 4:
        return 'four'
r = random.randint(1,5)
fort = getAn(r)
print(fort)
print(r)

print(getAn(random.randint(1,4)))

如果r的值为5时候,在def函数中没有对应的返回值,则返回None值