在Python中,我有一个脚本的这一部分:和我试图插入两个变量的时间和日期,但我得到一个错误
ip = ['10.25.128.225', '10.25.128.223', '10.25.128.224', '10.25.128.241']
time = time.strftime("%H:%M:%S")
date = time.strftime("%d/%m/%Y")
for address in ip:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((address, 9999))
if result != 0:
print('There is an issue with the {} address at {} on {} '.format(address, time, date))
每当我运行的代码,但是,我得到错误:
date = time.strftime("%d/%m/%Y")
AttributeError: 'str' object has no attribute 'strftime'
我想我必须建立一个数据类型,但我仍然是一种新的python /编程。有什么想法吗?谢谢!
命名你的时间变量不同 - 它阴影'时间'模块 –