python - 在过程 i while 循环之后添加增量有什么区别
问题描述
这两个代码有什么区别,我在第一个片段上得到无限循环
while (e <5):
print("hello)
e = e+1
第二个片段中的常规 while 循环
while (e <5):
e = e+1
print("hello)
解决方案
两个代码片段都按预期工作。您可能在第一个代码段中有缩进问题。
e = 0
while e < 5:
print("hello")
e = e + 1
e = 0
while e < 5:
e = e + 1
print("hello")
推荐阅读
- python-3.5 - 使用 python 从 PC 麦克风获取音频输入
- c# - 斯坦福 NLP - 识别各自的意图
- java - Android 使用带有 HTTPS 的 Ksoap2 请求
- javascript - 为什么 react-native init 不能正常工作?
- swift - Swift 4 通用 where 子句错误
- go - 将原始 Goreq.body 响应附加到文件
- c++ - C++:为什么 cout 使用 ifstream 从文件中读取的字符串打印回车?
- java - 在spring boot中构建war/jar时排除完整的包
- google-cloud-platform - 为什么 DialogFlow 中的不同语言有不同的系统实体?
- javascript - 如何用对应的变量替换 url 模式?