[Tutor] delete strings from specificed words

YU Bo tsu.yubo at gmail.com
Wed Jan 10 07:22:24 EST 2018


Hi,
On Wed, Jan 10, 2018 at 10:37:09AM +0100, Peter Otten wrote:
>YU Bo wrote:
>
>> index 45a63e0..3b9b238 100644
>> ...
>> ```
>> I want to delete string from *diff --git* to end, because too many code is
>> here
>
>Use str.split() or str.partition() and only keep the first part:
>
>>>> text = """The registers rax, rcx and rdx are touched when controlling
>IBRS
>... so they need to be saved when they can't be clobbered.
>...
>... diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
>... index 45a63e0..3b9b238 100644
>... """
>>>> cleaned_text = text.partition("diff --git")[0].strip()
>>>> print(cleaned_text)
>The registers rax, rcx and rdx are touched when controlling IBRS
>so they need to be saved when they can't be clobbered.

Cool,It is what i want.

Thanks all!

Bo

>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list