我有一个python脚本包含以下部分 -Python的正确缩进
import csv
import mechanize
"""
some code here
"""
with open('data2.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
for row in readCSV:
response2 = browser.open(surl+"0"+row[0])
str_response = response2.read()
if "bh{background-color:" in str_response :
print "Not Found"
else :
print "Found " + row[0]
s_index=str_response.find("fref=search")+13
e_index=str_response.find("</a><div class=\"bm bn\">")
print str_response[s_index:e_index]
当我试图运行这个文件,它显示在该行有一个错误
str_response = response2.read()
它
str_response = response2.read() ^IndentationError: unexpected indent
我是python的新手,无法弄清楚这段代码的正确缩进是什么。任何人都知道我在这里做错了什么?
你可能混和空间和选项卡缩进。 – Carcigenicate
混合制表符和空格? –
也许你在它前面混合了标签和空格。复制前一行的所有空白,并用str_response替换前面的空白。 – zwer