简体   繁体   中英

Receiving tab error “inconsistent use of tabs and spaces in indentation” even after converting from spaces to tabs in visual studio code

I keep receiving this error from my application:

File "", line 67

for o in obj["physical_address"]:
                                ^

TabError: inconsistent use of tabs and spaces in indentation

Here is my code:

@app.route('/location')
def get_testing_location():
    """Return selected state from drop down menu"""

    state = request.args['testing-state']
    url = f'https://covid-19-testing.github.io/locations/{state.lower()}/complete.json'
    res = requests.get(url)
    data = res.json()
    for obj in data:
        if obj["physical_address"]:
            for o in obj["physical_address"]:
                add=o["address_1"] 
                state=o["city"]
                print(f'{add} {state}')

    import pdb
    pdb.set_trace()

I have converted my visual studio code editor to use tabs instead of spaces and yet I still receive the same error.

  1. Add "editor.renderWhitespace": "all" in Settings.json. There may be spaces and tabs mixed in your code. It's recommended to indent all by spaces.

  2. Convert indentation to 4 spaces:

在此处输入图像描述

Save the file to see if the error goes away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM