python中.strip()
时间: 2023-10-24 15:32:34 浏览: 85
pythonstrip用法.docx
Python的strip()方法用于移除字符串头尾指定的字符,默认为空格。该方法的语法如下:str.strip([chars]),其中chars为可选参数,表示要移除的字符。strip()方法会返回移除指定字符之后生成的新字符串。例如,如果我们有一个字符串str = "0000000this is string example....wow!!!0000000",我们可以使用str.strip('0')来移除字符串头尾的0,得到结果"this is string example....wow!!!"。
参考资料:
: http://www.runoob.com/python/att-string-strip.html
: https://www.cnblogs.com/HITSZ/p/7097775.html<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [python中的strip()函数](https://blog.csdn.net/aoheng0603/article/details/101277980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [python strip()方法](https://blog.csdn.net/BBxxf90/article/details/84897670)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文