小编bmi*_*lis的帖子

strip() 删除多余的(不需要的)字符

在我的一个项目中,我对以下场景感到震惊:

word = 'mixed4d_pre_relu'
word.strip('_pre_relu')
Out[5]: 'mixed4d'
Run Code Online (Sandbox Code Playgroud)

这里的输出符合预期。

但是,当我执行以下操作时:

word = 'mixed4e_pre_relu'
word.strip('_pre_relu')
Out[5]: 'mixed4'  # No 'e' here, yyy?
Run Code Online (Sandbox Code Playgroud)

有谁知道这种行为的原因是什么?

python

1
推荐指数
1
解决办法
1318
查看次数

标签 统计

python ×1