用removeprefix(prefix)报错,有没有兄弟知道是怎么回事?
python3.8.5str1='今天天气真好'
>>> str1.removeprefix('今天')
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
str1.removeprefix('今天')
AttributeError: 'str' object has no attribute 'removeprefix' 本帖最后由 suchocolate 于 2021-1-29 10:57 编辑
python3.9才有
https://docs.python.org/zh-cn/3.9/whatsnew/3.9.html#new-string-methods-to-remove-prefixes-and-suffixes 百度翻译:
AttributeError:“str”对象没有“removeprefix”属性 貌似这是3.9才有的
页:
[1]