如何unnest一個嵌套列表或拼合一個嵌套列表。在python 3中編輯嵌套列表
,這樣,
servers = [["10.10.10.10" , "20.20.20.20"] ,["30.30.30.30"] , ["40.40.40.40", "50.50.50.50"] , ["60.60.60.60"],["70.70.70.70"]]
變,
servers = ["10.10.10.10" , "20.20.20.20"] ,["30.30.30.30"] , ["40.40.40.40", "50.50.50.50"] , ["60.60.60.60"],["70.70.70.70"]
所有幫助歡迎感謝
將['服務器=列表(鏈( *服務器))'](https://docs.python.org/3/library/itertools.html#itertools.chain)就夠了嗎? – Felk