简体   繁体   English

即使我在 UI_score 上加了 1,为什么 score_counter 没有更新?

[英]Even though I'm adding 1 to the UI_score, why isn't the score_counter updating?

UI_score = 0
player_score = 0
score_counter = str(UI_score) + "-" + str(player_score)
UI_score += 1
print(score_counter)

The score_counter is still giving me 0-0, when it should give me 1-0. score_counter 仍然给我 0-0,它应该给我 1-0。 Why is this happening?为什么会这样?

You update the variable after using the old value, try this instead:您在使用旧值后更新变量,请尝试以下操作:

UI_score = 0
player_score = 0
UI_score += 1
score_counter = str(UI_score) + "-" + str(player_score)
print(score_counter)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM