簡體   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)

score_counter 仍然給我 0-0,它應該給我 1-0。 為什么會這樣?

您在使用舊值后更新變量,請嘗試以下操作:

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