我已經看過以前對此的回答(python how to remove this n from string or list,remove a list item from a list和python remove whitespace in string),但無法使解決方案正常工作。Python從unicode列表中刪除製表符和運輸行
我有像這樣的單一元素的列表:
list = [u'\r\n\r\n\r\n \r\n \r\n \r\n 123 Main St., Peoria\r\n \r\n\r\n \r\n |\r\n \r\n \r\n \r\n \r\n 123-456-789\r\n \r\n \r\n \r\n ']
它有一個地址和電話號碼,我想就是有這個返回的是:
123 Main St., Peoria;123-456-789
我試過的東西,如:
str(list).strip(' \r\n\t')
和
str(list).replace('\r','')
但他們不工作,所以我想也許這是一個unicode問題?我如何解決它?
不要使用'list'作爲變量名,它掩蓋了內置類型。 –