Hỏi đáp

Chia sẻ kiến thức, cùng nhau phát triển

em muốn hỏi về lỗi result trong python ạ

khoảng 1 năm trước 699 lượt xem 1 bình luận

đoạn code gốc : 

if (import_mode == "1"):
    while (True):
        video = requestsurl("GET","http://tuberocket.app:3000/api/video", headers=headers_2, verify=False).json()

        delay_time(video["result"]["playSecond"])
        response_1 = requestsurl("PUT","http://tuberocket.app:3000/api/video", headers=headers_3, json={"id": video["result"]["videoId"], "playCount": 0, "playSecond": 0, "boost": 0, "status": "", }, verify=False).json()
        if (response_1["retMessage"] == "Success!!"):
            print("\033[1;97mStatus : retMessage -> Success!! -> result -> coin ->" ,response_1["result"]["coin"])
        else:
            print(response_1)

sau 1 thời gian chạy thì nó báo Lỗi Traceback (most recent call last): File "C:\xamppp\php\tube\ro.py", line 156, in <module> delay_time(video["result"]["playSecond"]) ~~~~~^^^^^^^^^^ KeyError: 'result'

Bình luận

Để bình luận, bạn cần đăng nhập bằng tài khoản Howkteam.

Đăng nhập
mt1234 đã bình luận khoảng 1 năm trước

Bạn viết bài ntn thì ai hiểu ạ

Theo mình bạn nên thêm 1 đoạn kiểm tra key "result" đã tồn tại hay chưa còn lại thì mình chịu tại code của bạn ít thông tin quá

Câu hỏi mới nhất