python - 在 y 增加后做 x
问题描述
我想在i
is 20
,40
等之后做一些事情。
例如:
i = 0
while True:
i+=1
if i == # increment of 20 (40, 60, 80, etc.):
# do this
解决方案
i = 0
while True:
i+=1
if i % 20 == 0: # increment of 20 (40, 60, 80, etc.):
print(i) #or something else
输出:
20
40
60
80
...
推荐阅读
- solr - 在 solr 8 中的 fl 中使用父过滤器时,获取“架构嵌套时不应发送父过滤器”
- service - 服务总线资源管理器
- webview - 我得到了 http 的 err_cleartext_not_permitted
- python - 寻找可以在单词级别执行 levenshtein/其他编辑距离的 python 库
- xml - 如何将xml转换为具有多个值和多个以空格分隔的标签的xml
- r - 使用循环生成汇总函数参数
- go - 主机密钥不匹配
- r - 在精确模式后提取 n 个字符/数字
- typescript - 在 Typescript 中使用带有 Webpack 和 worker-loader 的 WebWorkers,而无需自定义加载器字符串
- python-3.x - 带有流的 HoloViews DynamicMap 仅将显示输出一次传递给 IPython