我有一個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