python 去除如下字符串中 的所有中括号
'[[[[239,267]],[[238,268]],[[237,268]],[[236,269]],[[235,269]],[[234,270]],[[233,270]...
' [[[[239, 267]], [[238, 268]], [[237, 268]], [[236, 269]], [[235, 269]], [[234, 270]], [[233, 270]], [[232, 271]], [[232, 281]], [[240, 289]], [[241, 289]], [[241, 287]], [[242, 286]], [[242, 284]], [[243, 283]], [[243, 279]], [[244, 278]], [[244, 273]], [[243, 272]], [[243, 271]], [[242, 270]], [[242, 269]], [[240, 267]]]]'
展开
展开全部
用Python的replace函数就可以去除字符串中的所有中括号
完整的Python程序如下
#!/usr/bin/python
str = ' [[[[239, 267]], [[238, 268]], [[237, 268]], [[236, 269]], [[235, 269]], [[234, 270]], [[233, 270]], [[232, 271]], [[232, 281]],[[240, 289]], [[241, 289]], [[241, 287]], [[242, 286]], [[242, 284]], [[243, 283]], [[243, 279]], [[244, 278]], [[244, 273]], [[243,272]], [[243, 271]], [[242, 270]], [[242, 269]], [[240, 267]]]]'
out=str.replace('[','').replace(']','')
print(out)
运行结果
239, 267, 238, 268, 237, 268, 236, 269, 235, 269, 234, 270, 233, 270, 232, 271, 232, 281, 240, 289, 241, 289, 241, 287, 242, 286, 242, 284, 243, 283, 243, 279, 244, 278, 244, 273, 243, 272, 243, 271, 242, 270, 242, 269, 240, 267
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询