【发布时间】:2016-08-09 03:46:55
【问题描述】:
s = 'These are the characters, from this point I want to delete everything'
当 Python 看到“来自”时,我想删除之后的所有内容。
【问题讨论】:
-
s.rpartition('from')[0] -
@sstyvane
rpartition仅删除最后一次出现之后的内容。s.partition会更好