python - 每次重复 for 循环时减少变量
问题描述
stack_ypos
每次循环重复时,我都试图让 的值减少 50
def test_cards():
for i in range(5):
card_red(stack4_xpos, stack_ypos)
stack_ypos - 50
test_cards()
虽然它似乎没有做任何事情。
解决方案
您没有分配值的变化,因此您的变量不会改变!
def test_cards():
for i in range(5):
card_red(stack4_xpos, stack_ypos)
stack_ypos -= 50 # equivalent to stack_ypos = stack_ypos - 50
test_cards()
推荐阅读
- opencart - 缺少 Opencart 数据库表
- c# - 将 gsm 短信添加到文本框或列表框 (WinForm)
- java - Camel Java API 处理错误的数据格式
- typescript - ./node_modules/graphql/index.mjs 中的错误 49:0-53:205 无法重新导出命名导出
- object - Vue - v-用于附加计算道具
- dart - Flutter NestedScrollView/SliverAppBar - 不需要的底部边距
- java - 从 FirebaseRecyclerAdapter 获取文档 ID 并将值传递到新页面
- sql - 问:如何从 Oracle 中的 19 位数字中检索带时间(小时、分钟、秒)的日期
- java - 与 Firebase 数据库集成的 Spring 代码在 IDE 上运行良好,但在 Tomcat 上运行良好
- javascript - 同位素:根据宽度重新排序或打乱元素