【发布时间】:2016-03-15 17:31:36
【问题描述】:
我正在尝试创建一个用户输入来写入当前代码有效的文件,但我必须在它们周围写下我的答案,无论如何我可以只写是或 Y 而不必包含 ''
Join = input('Would you like to write to text file?\n')
if Join in ['yes', 'Yes']:
for key, value in ip_attacks.iteritems(): #for key(the IPAddress) and value(the occurrence of each IPAddress) in ip_attacks
if value > 30: #if the value (number of occurrences) is over 30
myTxtFile.write('\n{}\n'.format(key)) #then we want to write the key(the IPAdress) which has been attack more than 30 times to the text file
else:
print ("No Answer Given")
【问题讨论】:
标签: python python-2.7 input