0

I create JSON, I need to replace some string by number. Here is my code:

row[1] = row[1].replace('Neuf', '1')

The problem is that I end up with "1" when I would like to have the number 1...

1 Answer 1

1

Using str.replace will always result in a str. If you want an int, do the following:

row[1] = 1 if row[1] == 'Neuf' else row[1]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.