如何从列表中删除列表中的双引号

时间:2019-08-19 04:10:34

标签: python

我有一个清单,假设

open = () => { ... }
<button onClick={this.open}

我希望我的输出是这样的(删除双引号)

select *
from (
  select commission_date, agent_id, agent, team, [role], [target], [collection], commission, final_payout 
    , row_number() over(partition by agent_id order by case when team = 'Team Lead' then 1 else 0 end desc) row#
  from ambank.dbo.commissions
  where commission_date = '2019-06-30' and ([target] > 0 or final_payout > 0)
  and agent_id in (4446,2267)
) x
where row# = 1
order by agent;

我尝试使用此

但是我仍然可以看到引号,实现此目的的最佳方法是什么。

m = [["'ghvghvgh hgdghdh', 'hxjhsdhb.com - Error 404:validation', 'jhhscbhjbcsd', 'hghs'"],["'ghvh', 'hxjhsdhb', 'jhhcsd', 'hs'"]]

2 个答案:

答案 0 :(得分:2)

要使数据规范化,您需要替换单引号而不是双引号以删除多余的空格。

lst = [
    i[0].replace("'", '').strip().split(', ') 
    for i in m
]

答案 1 :(得分:0)

import re 
a=re.compile('[a-zA-Z]+')
m = [["'ghvghvgh', 'hxjhsdhb', 'jhhscbhjbcsd', 'hghs' "],[" 'ghvh', 'hxjhsdhb', 'jhhcsd', 'hs'"]]
res= [[a.findall(i) for i in j][0] for j in m]
print(res)

输出

[['ghvghvgh', 'hxjhsdhb', 'jhhscbhjbcsd', 'hghs'], ['ghvh', 'hxjhsdhb', 'jhhcsd', 'hs']]