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

n = '[123,456,789]'

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

print(n)

>>>123456789