The error "string indices must be integers" occurs when you try to use a string as an index in Python. In this case, it seems like you are using a string as an index while accessing the "elements" key in the dictionary.

To fix this error, make sure that you are using an integer index or a valid dictionary key to access the desired value. Check if the "elements" key exists in the dictionary before accessing it. Here's an example of how you can modify your code:

if not any("elements" in rj and rj["elements"] for rj in response_jsons):
    # Your code here

In this updated code, we first check if the "elements" key exists in the dictionary before accessing it. If it doesn't exist or the value is empty, the condition will evaluate to False

if not anyrjelements for rj in response_jsons 提示 string indices must be integers

原文地址: https://www.cveoy.top/t/topic/ioJA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录