【发布时间】:2020-09-09 01:55:02
【问题描述】:
问题:从字符串列表中找到所有明确包含子字符串的名称并返回该字符串。
我有一个熊猫系列,比如:
231 richard occult (new earth)
6886 bedivere (new earth)
705 arthur pendragon (new earth)
567 franklin delano roosevelt (new earth)
1468 lancelot (new earth)
...
6891 nadine west (new earth)
6892 warren harding (new earth)
6893 william harrison (new earth)
6894 william mckinley (new earth)
6895 mookie (new earth)
6896 Superboy (new earth)
我有一个希望与每个名称匹配的特定子字符串的列表,即:
boy_names = ['Mr.', 'Boy', 'Man', 'Lord', 'King',
'Brother', 'Sir', 'Prince', 'Father', 'Lad',
'Baron', 'He-',' He' 'Son', 'Duke','Son','Dad', 'Senior',
'Junior', 'Master']
所需输出:Superboy
【问题讨论】: