Shi*_*dla 3 python string list
假设我有以下列表
list_fields = ['Full-Time',
'Options:',
'Express your interest',
'Email this to a friend',
'More information about this job:',
'Overview:',
'A',
'Parasite',
'position is cool',
'Are you a LEADER?',
'For sure there',
'Hello doing?',
'If so you will EXCEL.',
'Bring your skills',
'programs and procedures']
Run Code Online (Sandbox Code Playgroud)
我想要做的是收集所有字符串后overview,我的意思是需要忽略字符串之前的overview字符串.之前和之后可能有很多字符串overview,但是只想在overview列表之后收集所有字符串,并希望通过使用像''.join([list_fields])
对不起的东西将它们作为单个字符串,如果我一次又一次地使用单词,有人可以告诉我如何做这个
Edited Code:
Run Code Online (Sandbox Code Playgroud)
提前致谢
如果你知道字符串是litterally "Overview:",你可以做
''.join(list_fields[list_fields.index("Overview:") + 1:])
Run Code Online (Sandbox Code Playgroud)
这用于list.index()确定"Overview:"列表中的索引,并使用切片从后面的索引处获取子列表"Overview:".
| 归档时间: |
|
| 查看次数: |
99 次 |
| 最近记录: |