[英]How to make sure that the values of the numbers are preserved?
我希望它在輸入命令時先顯示 7,然后顯示 4、1,但它總是顯示 7、7、7
@client.command()
async def test(ctx):
bint = 3
money1 = 10
if money1 >= 3:
money1 = money1 - bint
await ctx.send(money1)
您可以為此使用全局變量或將變量存儲在其他地方。 我通常做的是在基本目錄中創建一個config.py
文件,然后將變量放在那里
配置文件
money1 = 10
在你的代碼中
import config
bint = 3
if config.money1 >= 3:
config.money1 - bint
await ctx.send(config.money1)
您也可以像這樣使用您的不和諧客戶端(不推薦):
try:
client.money1
except:
client.money1 = 10
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.