に値を追加し、私はCSVが csv filePythonの辞書
Asset IP Address,Vulnerability Title
50.103.128.11,Partition Mounting Weakness
10.103.128.11,UDP IP ID Zero
10.103.128.11,Root's umask value is unsafe
0.103.128.11,Root's umask value is unsafe
20.103.128.11,Root's umask value is unsafe
10.103.128.11,ICMP timestamp response
22.103.128.11,ICMP timestamp response
10.103.128.11,UDP IP ID Zero
10.103.129.11,Partition Mounting Weakness
を提出し、
import csv
from pprint import pprint
#with open('test.csv', 'rb') as f:
# reader = csv.DictReader(f, delimiter=',')
# for row in reader:
# print row
#dict = {a:[], b:[]}
dict = {}
with open('test.csv', 'rb') as f:
reader = csv.DictReader(f, delimiter=',')
for row in reader:
a = row["Vulnerability Title"]
b = [row["Asset IP Address"]]
#b = row(["Asset IP Address"])
#dict = {a:[], b:[]}
if a in dict:
#print row["Vulnerability Title"]
#if row["Vulnerability Title"] in dict:
dict[a].append(b)
else:
dict[a] = b
pprint(dict)
私のスクリプトを実行した後に、脆弱性のリストを読み込み、持っているIPSで辞書を作成読み込むスクリプトを持っていますその脆弱性。私の結果は1つの余分な括弧を持つリストです。誰かがより良いアイデアを持っているのを見たり、私を助けたりすることができます。 results
{'ICMP timestamp response': ['10.103.128.11', ['22.103.128.11']],
'Partition Mounting Weakness': ['50.103.128.11', ['10.103.129.11']],
"Root's umask value is unsafe": ['10.103.128.11',
['0.103.128.11'],
['20.103.128.11']],
'UDP IP ID Zero': ['10.103.128.11', ['10.103.128.11']]}
あなたがoutterを必要としない '[]'で 'B = [行[」 Asset IP Address "]]' – innoSPG