2016-03-28 5 views
1

ホスト名とIPアドレスを取得し、リストに書き込んで別の辞書に入れることができるスクリプトを作成しようとしています。変数に数値がないという事実を除いて、私はちょうど 'を得ます。番号ではなく部分である。これは前に私に起こっていないように私が間違ってやって本当にわからない...見てみましょう:それはちょうど追加forループからリストにIPアドレス文字列を追加する問題

C:\Users\fallacy>a_record_add.py 
How many hosts will need records? 1 
What is the hostname of the host: test 
What is the IP address of the host: 192.168.1.1 
['test'] 
[[...]] 
{'test': [[...]]} 

HOST_NAME = [] 
IP_ADDRESS = [] 

ADDITION_NAME = "Please enter a word or two explaining the addition (used for file name): " 

ENTRY_AMOUNT = int(input("How many hosts will need records? ")) 

for number in range(ENTRY_AMOUNT): 
    hostname = raw_input("What is the hostname of the host: ") 
    address = raw_input("What is the IP address of the host: ") 
    HOST_NAME.append(hostname) 
    IP_ADDRESS.append(IP_ADDRESS) 


A_RECORD_ENTRY = dict(zip(HOST_NAME,IP_ADDRESS)) 


print HOST_NAME # test for correct appendages 
print IP_ADDRESS # test for correct appendages 
print A_RECORD_ENTRY # testing code for dictionary output 

これは私の出力を与えています私が間違ってやっていることを私に知らせておいてください。とても有難い!

答えて

2
IP_ADDRESS.append(IP_ADDRESS) 

は、私はあなたが書くためのものだと思う:

IP_ADDRESS.append(address) 
+0

は確かに完全にそれを見落として、ありがとうございました! – Fallacy11

+0

これがあなたの問題を解決したならば、@ケビンの答えを受け入れて、他の人が答えを書く必要がないことを知ってください!ありがとう! –

関連する問題