python - Python代码只在我运行时说不?
问题描述
我在 repl.it 中对此进行了编码,但它不起作用。谁能告诉我为什么?
import random, sys
mynumber = random.randint(1, 31)
month = 0
print("password cracker 1.0")
username = input("Email: ")
year = input("Year that they were born: ")
while True:
if month == mynumber and year == 2006:
print("yes")
print(month)
sys.exit(0)
else:
print("no")
month + 1
解决方案
您需要比较兼容的类型。任何一个
int(year) == 2006
或者
year == "2006"
"2006"
返回的字符串input
不等于int
value 2006
。
推荐阅读
- c# - Unity:如何将相机沿切平面定向到球体?
- php - Laravel 发布带有 nodejs MethodNotAllowedHttpException 405 错误的帖子
- angular - 如何使用具有 7/8 角度的语言环境和 fullCalendar
- java - java - 当没有显示错误时,如何修复未在java中执行的main方法?
- c++ - 如何在 C++ 中实现静态类?
- python - 使用另一个数组/列表的 Python 索引
- flutter - 当我向上滚动时,如何使 sliverAppBar 只显示缩小的条(浮动:真)
- sql - 使用没有 FK 且在所有表中具有相同 id 的聚合函数加入 2 个以上的表
- python - 通过其中一个中的重复元素过滤两个不规则列表
- java - 搜索基于 java 的电报 api 代码