我正在處理數據,並且已將它設置爲吐出我需要的項目。 例子:如果符合關鍵字,則返回函數中的第一個數字
LOT OF 4 American motor vinegar
Lot of (6) 808 metal/steel/G/N LWAP
LOT 12 product number 57838290
我想是有它在每個批次吐出量,可能是小寫或大寫,如果'lot'
在文本中找到。我認爲我的代碼已經建成了一半,但由於該值不在設置的位置,我不知道如何檢索它。另外,上面的列表是從文本字符串,因此它不承認整數
def auction(title):
for word in title.split():
if word.startswith('lot'):
return # not sure what to return (from the example the answer would be 4 6 and 12)
*由於該值不在設定的位置,我不知道如何檢索它*循環播放直到找到一個數字的字符串,並在找到第一個不是第一個字符串時停止循環一個數字 –