[英]How to make sure that the values of the numbers are preserved?
I want it to show 7 first, then 4, 1 when entering the command, but it always shows 7, 7, 7我希望它在输入命令时先显示 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)
You can use a global variable for that or store the variable somewhere else.您可以为此使用全局变量或将变量存储在其他地方。 What I usually do is make a config.py
file in the base directory and then put variable there like我通常做的是在基本目录中创建一个config.py
文件,然后将变量放在那里
config.py配置文件
money1 = 10
in you code在你的代码中
import config
bint = 3
if config.money1 >= 3:
config.money1 - bint
await ctx.send(config.money1)
You can as well use your discord client (not recommend) like this:您也可以像这样使用您的不和谐客户端(不推荐):
try:
client.money1
except:
client.money1 = 10
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.