python - 从列表中删除括号和引号
问题描述
filter_col
下面的列表给了我这样的列表:
['RP026_IP_1_S9_L001_R1_001']
['RP026_IP_2_S10_L001_R1_001']
['RP026_IP_3_S11_L001_R1_001']
['RP026_IP_4_S12_L001_R1_001']
如何删除括号并使其更像这样:
RP026_IP_1_S9_L001_R1_001
RP026_IP_2_S10_L001_R1_001
RP026_IP_3_S11_L001_R1_001
RP026_IP_4_S12_L001_R1_001
这就是我列出清单的方式:
treated_sample = ["RP026_IP_1_S9_L001_R1_001",
"RP026_IP_2_S10_L001_R1_001",
"RP026_IP_3_S11_L001_R1_001",
"RP026_IP_4_S12_L001_R1_001"]
for i in treated_sample:
filter_col.append([col for col in df if col.startswith(i)])
解决方案
例如,如果它在一个变量名中
你可以做 :
a.replace("['", "").replace("']")
推荐阅读
- android - 在 Firebase 上使用具有相同位置值的相反用户填充数组
- node.js - 如何在 react-native 中实现 azure 服务总线?
- caching - 主存是易失性存储器,如何保证数据不丢失?
- docker - Linux docker 镜像可以在 Windows 和 Mac 上运行吗?
- javascript - 如何更改 li 标签内的特定组件(reactjs);
- python - 如何根据从一列到另一列的正则表达式过滤行
- selenium-webdriver - Webdriver Sampler 在 Windows10 中不起作用
- laravel - AlpineJs 选择框绑定文本而不是值
- angular - 单击父组件中的保存按钮时如何从子组件获取数据到父组件?
- node.js - 努力在 Node js 中使用 Knex 编写一个 SELECT 查询来进行计算