【发布时间】:2022-06-13 17:52:50
【问题描述】:
我正在尝试使用 python 运行以下循环,但不断出现错误
文件“”,第 2 行
IndentationError: 在第 1 行的“for”语句之后需要一个缩进块
对于 df.index 中的 i:
for i in df.index:
try:
location = geolocator.geocode(df['query'][i])
df.loc[i,'location_lat'] = location.latitude
df.loc[i,'location_long'] = location.longitude
df.loc[i,'location_address'] = location.address
except:
df.loc[i,'location_lat'] = ""
df.loc[i,'location_long'] = ""
df.loc[i,'location_address'] = ""
我必须提到我正在使用 Visual Studio 代码来制作我的脚本。我会感谢所有建议。
【问题讨论】:
-
请包含完整的回溯错误。
标签: python database indentation