我寫此塊:列表操作錯誤輸出
stst = "Hello [email protected]#"
empt = []
def shplit(stst):
tst = stst.split()
print tst
for i in tst:
empt = list(i)
print empt
shplit(stst)
我從打印得到的是:
['Hello', '[email protected]#']
['W', 'o', 'r', 'l', 'd', '!', '@', '#']
我想不通,爲什麼單詞「你好」不會出現完全在第二個列表中。 這是怎麼發生的?
用你自己的話說,爲什麼*應該*它附上AR?逐步瀏覽它,並解釋你在每一步都會遇到'empt'。 –