我在Python中有一個字典,它描述了在各種主機上運行的某些類型的二進制文件。其中一些與其他相連。問題是 - 我怎樣才能從他們那裏構建鏈條?如果輸入和輸出相同,則連接二進制文件。 例如:用python提取鏈序列
{"binary1": "bin1", "input": "127.0.0.1:2222", "output": "127.0.0.2:3333", "other_stuff": "....1111..."}
{"binary2": "bin2", "input": "127.0.0.2:3333", "output": "", "other_stuff": "....2222..."}
{"binary3": "bin3", "input": "128.0.0.1:5555", "output": "127.0.0.2:7777", "other_stuff": "....3333..."}
{"binary4": "bin4", "input": "127.0.0.2:8888", "output": "127.0.0.2:4444", "other_stuff": "....4444..."}
{"binary5": "bin5", "input": "127.0.0.1:9999", "output": "127.0.0.2:8888", "other_stuff": "....5555..."}
{"binary6": "bin6", "input": "127.0.0.5:1111", "output": "127.0.0.9:1234", "other_stuff": "....6666..."}
{"binary7": "bin7", "input": "", "output": "127.0.0.1:9999", "other_stuff": "....7777..."}
{"binary8": "bin8", "input": "127.0.0.1:2222", "output": "127.0.0.2:3333", "other_stuff": "....8888..."}
{"binary9": "bin9", "input": "", "output": "127.0.0.5:1111", "other_stuff": "....9999..."}
{"binary0": "bin0", "input": "", "output": "", "other_stuff": "....0000..."}
預期輸出:
bin1 -> bin2
bin7 -> bin5 -> bin4
bin9 -> bin6
輸入和輸出是沒有必要爲每個二進制。
最後,我需要製作鏈表並繪製它們,但它是一個獎金:)是否存在一些python模塊,這將有助於提取序列並做到足夠快? (數據大小約爲10萬個二進制文件)。
在此先感謝!
P.S.其實我需要鏈接到python模塊,這將有助於我解決它(而不是算法),這就是所有
否)))我在20年前完成了我的最後作業。 – DominiCane 2011-12-26 14:00:28
擁有名稱字段的動態鍵是一個愚蠢的想法。這個子問題(即如何從'{「binary1」:「bin1」,..}')找到''bin1''應該先解決。 – phihag 2011-12-26 14:12:27