我'湊了過去的斷言語句錯誤,但我不無爲什麼請幫我將字符串轉換爲set時出現編譯時錯誤?
def test_set_creation():
"""
sets can be created from any sequence like list or a tuple.
"""
test_list = [1, 2, 1, 3]
set1 = set(test_list)
assert {1,2,3} == set1
test_string = "apple"
set2 = set(test_string)
assert {} == set2
您在這裏沒有收到'編譯時錯誤'。充其量,你會得到一個斷言例外。 – 2014-12-04 14:08:32