减去值Python36

时间:2019-04-28 11:21:12

标签: python-3.x

我尝试从request.get(“ http://link/test.txt”)减去值

test.txt = 5

我尝试减去5-1

我的代码:

count1 = requests.get('http://link/test.txt')

@client.event
async def on_ready():
await client.change_presence(game=discord.Game(name='test : '+ str(count1.text) - int(1), type=1))

我想获得5-1 = [最终结果是:4]作为bot状态“测试:4”

  

TypeError:-:“ str”和“ int”的不受支持的操作数类型

1 个答案:

答案 0 :(得分:1)

您需要将字符串转换为数字:

count1 = requests.get('http://link/test.txt')

@client.event
async def on_ready():
    await client.change_presence(game=discord.Game(name='test : ' + str(int(count1.text) - 1), type=1))
相关问题