在这行代码中:
Good = input('Am i Good? > ').upper()
您将输入转换为大写,然后将该字符串与小写字符串进行比较(“no”、“quit”)。这永远不会匹配,因为 "NO" 和 "no" 是不同的字符串(Python 在比较字符串时关心大小写)。
“no”
“quit”
"NO"
"no"
In this line of code:
You transform the input to uppercase, but then you compare the string with lowercase strings ("no", "quit"). This will never match since "NO" and "no" are different strings (Python cares about case when comparing strings).
"quit"
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
在这行代码中:
您将输入转换为大写,然后将该字符串与小写字符串进行比较(
“no”
、“quit”
)。这永远不会匹配,因为"NO"
和"no"
是不同的字符串(Python 在比较字符串时关心大小写)。In this line of code:
You transform the input to uppercase, but then you compare the string with lowercase strings (
"no"
,"quit"
). This will never match since"NO"
and"no"
are different strings (Python cares about case when comparing strings).