簡體   English   中英

TypeError: 'int' object 不可下標。 現在我該怎么辦?

[英]TypeError: 'int' object is not subscriptable. now what should i do?

我有代碼:

def nob(message):
    inp = message.text
    jum = len(inp)
    angka = random.randint(0,100)
    if jum < 8:
        client.reply_to(message, "please input the name!")
    else:
        client.reply_to(message, jum[inp:8] + " Is " + str(angka) + "% nob!")

這是這樣的錯誤:

client.reply_to(message, jum[inp:8] + " Is " + str(angka) + "% nob!")
TypeError: 'int' object is not subscriptable.

我應該怎么辦?

表達式jum[inp:8]引發了異常。 jum已設置為len(inp) ,這是一個 integer 並且整數不可下標:像1[2]這樣的表達式沒有任何意義。 你不是說 inp inp[inp:8]嗎? 或者只是inp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM