import urllib.request as u
zipcode = str(47401)
url = 'http://watchdog.net/us/?zip=' + zipcode
con = u.urlopen(url)
page = str(con.read())
value3 = int(page.find("<title>")) + 7
value4 = int(page.find("</title>")) - 15
district = str(page[value3:value4])
print(district)
newdistrict = district.replace("\xe2\x80\x99","'")
print(newdistrict)
出于某种原因,我的代码以以下格式提取标题:IN-09: Indiana\xe2\x80\x99s 9th
. 我知道\xe
字符串是'
符号的 unicode,但我不知道如何让 python 用'
符号替换那组字符。我试过解码字符串,但它已经是 unicode 并且上面的替换代码没有改变任何东西。关于我做错了什么有什么建议吗?