python去掉字符串之间的逗号和括号

 去掉字符串中不想要的逗号,括号等

n = '[123,456,789]'

n = n.replace(',', '')  # 去掉逗号
n = n.replace('[', '')  # 去掉左括号
n = n.replace(']', '')  # 去掉有括号

print(n)

>>>123456789

 

posted @ 2022-03-17 19:13  博无止境  阅读(2763)  评论(0编辑  收藏  举报