所以Heres我的代码
while True:
username = raw_input("Username:")
time.sleep(1)
print username
qwerty = raw_input("Is this right?")
if qwerty == 'yes' or "Yes" or "Yeah" or "yeah" or "yup" or "Yup":
print "OK."
break
elif qwerty == 'no' or 'No' or 'nope' or 'Nope' or 'nah' or 'Nah':
print "Please type your Username again"
continue
else:
print "Please Try a more common answer"
continue`
我不知道什么是错的,因为我输入的内容只有第一个选项出来。有谁知道为什么?
答案 0 :(得分:2)
您需要在 document.addEventListener('DOMContentLoaded', function () {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Google Chrome.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function timerFinishNotify() {
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Break Time!', {
icon: '../img/icon.png',
body: 'You worked hard, time for a break.',
});
notification.onclick = function () {
window.focus(),
this.close();
};
}
};
function breakFinishNotify() {
var notification = new Notification('Work Time!', {
icon: '../img/icon.png',
body: 'Break time is over, time to be productive.',
});
notification.onclick = function () {
window.focus(),
this.close();
};
};
中将条件更新为:
if
解释:
Python中的 if qwerty in ['yes', "Yes", "Yeah", "yeah", "yup", "Yup"]
执行逻辑or
操作。如果值为OR
,则满足条件,否则它将转到True
中的下一个条件。为了让您更清晰。例如:
or
另请注意,python将非零和非空字符串值视为>>> 'Hello' or 'Man'
'Hello'
>>> '' or 'Man'
'Man'
。
您的案例示例:
True