有关字符串的python问题

时间:2014-02-20 14:39:16

标签: python-3.x

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

计算机告诉我你的shut_down函数引发了以下错误:'str'对象没有属性'Lower'

1 个答案:

答案 0 :(得分:1)

您的.Lower()在python中不可用,因为它使用区分大小写的语言.lower()

     def shut_down(s):
         s = s.lower()

         if s  == 'yes' :
              return "Shutting down..."
         elif s ==  'no':
              return "Shutdown aborted!"
         else :
             return "Sorry, I didn't understand you."