无法比较python中的ip地址

2024-06-12 11:44:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码是这样的

from socket import gethostbyname, gethostname
with open('LoggedIn.csv', 'r') as csvfile:
    aList = []
    for line in csvfile.readlines():
        array = line.split(',')
        aList.append(array[2])
ip = gethostbyname(gethostname())

if ip in aList:
    x = 1
else:
    x = 0

当我得到用户的ip地址并且在我的登录.csv提交if语句只返回false。在

谢谢你!在


Tags: csvcsvfile代码infromimportipif