Thread Status:
Not open for further replies.
  1. So i was testing my python thing i have been working on when i decided to put hypixel's name in and it gave me an error and i didn't know why but i finally figured out that anyone that doesn't have any stats for a game/gamemode it gives me errors! HELP! (I am using snuggles wrapper)

    correction:
    if the player has no stat for the stat it's requesting so like it's getting messed up when it tries to get hypixel's final kills in solo (he has none) so it's give me errors

    message
    Code:
    Traceback (most recent call last):
      File "N:\Need_Not\Documents\hypixel api\hypixel.py-master\hypixel_index.py", line 119, in <module>
        bw2 = (playerJSON['stats']['Bedwars']['eight_one_final_kills_bedwars'])
    KeyError: 'eight_one_final_kills_bedwars'
     
    #1
  2. Since you're using Python, you can use try and except statements if you're using a wrapper. Or, you can make requests to the API without the wrapper and check if the key exists within the JSON response.
    [​IMG]
    [​IMG]
     
    #2
  3. wait so i'll have to do that to every line? or is there a way to do it to anything at once?
     
    #3
  4. PROBLEM FIXED:
    solution
    Code:
    print("Kills: %d" % (getInfo(Player.JSON, "eight_one_kills_bedwars")))
    print("Kills: %d" % (getInfo(Player.JSON, "eight_one_deaths_bedwars")))
    print("K/D: %.2f" % (getInfo(Player.JSON, "eight_one_kills_bedwars")/getInfo(Player.JSON, "eight_one_deaths_bedwars")))
     
    #4
  5. TorWolf

    TorWolf Alpharator | Forum Team

    TorWolf
    Mod
    Moonlit WOLF
    GUILDMASTER
    Messages:
    2,058
    Creator requested lock, so I'm locking the thread :)
     
    #5
    • Useful Useful x 1
Thread Status:
Not open for further replies.

Share This Page