python - python - 删除每个使用开始和结束字符
问题描述
我可能很简单,使用正则表达式,我无法使用开始和结束字符删除一些字符。
string = 'this is my test (20)'
基本上我想在左括号之前打印。
this is my test
我试过分裂
string = '('.join(split[:0]))
不确定正确的语法,。
解决方案
使用split
andstrip
删除字符串末尾的多余空格
print(string.split("(")[0].strip())
推荐阅读
- node.js - 使用 passport-facebook-token 进行用户注册羽毛身份验证
- c# - 在 ASP 中调用数据库上下文时出错。NET 应用程序 [VISUAL STUDIO 2012]
- sql-server - 如何在 Azure 数据工厂中使用预复制脚本来删除空/特殊字符行?
- python - 如何格式化 groupby year 函数 pandas - 返回 unicode 属性错误
- ios - 按照用户方向旋转collectionView
- bigcommerce - 自定义 BigCommerce 产品列表
- c# - 在 Sqlite 中本地评估的实体框架 2.0 左外连接
- nativescript - 为什么 couchbase 插件不加载?
- ajax - ajax调用失败后如何访问捕获所有路由而不使用react-router更改URL
- angular - Ionic 4 中的组件