我正在编写一个基本的python程序来检查字符串列表中是否出现了一个字符串

2024-04-25 09:40:36 发布

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

如何在python中检查列表中是否存在字符串?你知道吗

with open('pwds.csv', newline='\n') as csvfile:
global passwordlist
passwords = csv.reader(csvfile,delimiter=',')
passwordlist = []
for row in passwords:
    global passwordlist
    passwordlist = list(passwords)
    map(lambda passwordlist: str.replace ("['", ""), passwordlist)
    print (passwordlist)

我尝试将数据存储在CSV文件中,然后用python读取它,以查看它是否包含用户输入中给定的字符串。目前,程序总是无法在列表中找到输入的字符串,即使我让程序打印列表以确保字符串确实存在。我只是迷路了。 对于扩展工作来说,这是一项GCSE计算挑战性任务。你知道吗


Tags: csvcsvfile字符串程序列表aswithnewline