Python csv' s - 找到结果后的下一个单元格

时间:2014-12-10 18:31:56

标签: python csv python-3.x python-3.4

我有代码:

def checkdetails(username, password):
    with open('Data.csv', 'rt') as f:
        reader = csv.reader(f, delimiter=',')
        for row in reader:
            print(row)
            if username == row[0]:
                #This is where i will need to check if the password in the next column matches

这将搜索csv的第一列,以查看用户名是否存在。它有效。

接下来我需要做的是移动到该行的下一列,如果它与值匹配

1 个答案:

答案 0 :(得分:1)

只是做:

if row[0] == username and row[1] == password: