Skip to main content
 首页 » 编程设计

python之为什么我的条件返回 "none"

2025年05月04日9arxive

<分区>

每当我运行它时,当它应该返回第一个时,我会得到第三个选项,因为 s = 'yes'。这里出了什么问题?

def shut_down(s): 
    if s is 'yes': 
        return 'Shutting down...' 
    elif s is 'no': 
        return 'Shutdown aborted!' 
    else: 
        return "Sorry, I didn't understand you" 
 
ans = 'Yes' 
s = ans.lower() 
shut_down(s)