我的代码看起来像这样
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地址并且我的LoggedIn.csv文件中有相同的IP地址时,if语句只返回false。
谢谢!