我使用python查询mysql数据库,同一个实例跨库查询 ,从上一个数据库重查到数据,作为下一个sql 的参数,遇到了一些问题 ,再次记录一下
前提 我的sql需求:
select count(1) as count from dc_dwd_distribute where distribute_channel=100002 and status=3 and user_sid in ('1113253444','4295135603','4295135604')
其中in 部分是另一个数据库中查出来的数据
1 in部分查出来是这个格式 (格式是 str 字符串)
[1113253444], [4295135603], [4295135604], [4295135732], [4295135850], [4295135851],
2 我要转换成下边儿这个格式
'1113253444','4295135603','4295135604'
解决方法:(思路 把中括号替换成单引号)
ss = list(strData)
for x in range(len(ss)):
if ss[x] == '[':
ss[x] = "'