【发布时间】:2021-12-29 04:41:18
【问题描述】:
所以我得到了一个包含名称的列表,我正在尝试从列表中删除这些名称。但不知何故,它并没有按照我想要的方式工作。任何帮助将非常感激。我认为问题出在替换功能上,但我不确定。
功能:
@pyqtSlot(str, str)
def rapportmail (self, email, wachtwoord):
credentials = Credentials(email, wachtwoord)
acc = Account(email, credentials=credentials, autodiscover=True)
cursor.execute("SELECT DISTINCT Naam FROM Klant")
updatedklant = str(cursor.fetchall())
test = updatedklant
for item in acc.inbox.all().order_by('-datetime_received')[:500]:
inboxmail = str(item.sender).split("'")
currentinboxmail = inboxmail[3]
cursor.execute("SELECT DISTINCT Klant FROM Mail WHERE Mail=?", currentinboxmail)
currentklant = str(cursor.fetchall())
remove_characters = ["(",")",",","]","["]
for characters in remove_characters:
currentklant = currentklant.replace(characters, "")
if currentklant not in updatedklant:
for idx, elem in enumerate(test):
if elem[0] == currentklant:
test.pop(idx)
现在打印这个:
currentklant == 'alerttesting'
test == [('alerttestting', ), ('emretestingsystems', ), ('jarnodebaas', ),('yikes', )]
结果应该是:
currentklant == 'alerttesting'
test ==[('emretestingsystems', ), ('jarnodebaas', ),('yikes', )]
【问题讨论】:
标签: python exchangewebservices