我很難理解這個循環。我是新的python,所以我不明白到底發生了什麼。該代碼是爲html轉義。Python for循環與它的元組
我的問題是:如何執行for循環?爲什麼對(i,o)在(.........)中這是如此的真實?它如何知道字符串s中有一個&符號?
def escape_html(s):
for(i,o) in (("&", "&"),(">",">"),('<','<'),('"',""")):
s=s.replace(i,o)
return s
print escape_html("hello&> this is do\"ge")