str.strip() strange behavior

前端 未结 5 707
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 08:25
>>> t1 = "abcd.org.gz"
>>> t1
\'abcd.org.gz\'
>>> t1.strip("g")
\'abcd.org.gz\'
>>> t1.strip("gz")
         


        
5条回答
  •  萌比男神i
    2020-11-27 09:10

    The argument given to strip is a set of characters to be removed, not a substring. From the docs:

    The chars argument is a string specifying the set of characters to be removed.

提交回复
热议问题