How to change 000-000 to 000000 in Python?

时间:2018-06-04 17:26:41

标签: python python-2.7 odoo-10

I'm making an odoo10 module, but I need to change a string like

000-000

to

000000

How can I do that?

2 个答案:

答案 0 :(得分:0)

print("000-000".replace("-", "")) #Output: "000000"

答案 1 :(得分:-1)

Try this

Oldstr = “000-000”
Newstr = Oldstr.replace(“-”,””)

That should do it. What I did:

  1. Make the string “000-000”
  2. Made a new string and replaced the “- ”in the old one with nothing and saved it in a new variable