【发布时间】:2012-07-13 14:24:09
【问题描述】:
如何获取字符串中'\id ' 之后的第一个单词?
字符串:
'\id hello some random text that can be anything'
蟒蛇
for line in lines_in:
if line.startswith('\id '):
book = line.replace('\id ', '').lower().rstrip()
我得到了什么
book = 'hello some random text that can be anything'
我想要什么
book = 'hello'
【问题讨论】: