python小技巧(持續更新)

1.eval()函數 eval函數就是實現list、dict、tuple與str之間的轉化,這在爬蟲處理數據時十分有用。python # 字符串轉換成列表 a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]" print(type(a)) b = eval(a) print(b) # 字符串轉換成字典 a = "{1: 'a', 2: 'b'}" print(type
相關文章
相關標籤/搜索