gpt4 book ai didi

Python rstrip() 工作起来很奇怪

转载 作者:行者123 更新时间:2023-12-04 00:00:11 32 4
gpt4 key购买 nike

我遇到了一个对我来说非常奇怪的问题。

str.rstrip([chars])

在一个例子中,我的工作方式真的很奇怪。 (或者我可能错过了一些重要的文档部分)。

>>> 'car_id__isnull'.rstrip('__isnull')
>>> 'car_id' # works fine
>>> 'last_success__isnull'.rstrip('__isnull')
>>> 'last_succe' # I do not understand why this happened ?

谢谢,提前。

最佳答案

这是因为您误解了 rstrip 的作用。它从字符串的右侧删除所有出现的任何给定字符

Documentation非常擅长描述这类事情。

关于Python rstrip() 工作起来很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62907448/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com