I have 32 dictionaries and I need to change the quotation marks of each object, since they are incorrectly placed, with a replace or something, can it?

0

I'm doing a project and we're working with 400 and the rest of the files, most of them went wrong and the quotes were placed wrongly, is there any way to not have to replace one by one and do it with some Python function to replace the misplaced quotation marks by some well placed?.

Ejm:

{“nombre”:”Buffon”,”numero”:”00”,”tiempojugado”:”123”,”amarillas”:”2”,”goles”:”6”,”posición”:”Portero”}

The same quotes were placed and I want to know if they can be replaced by these "" since in the dictionaries the closing ones are placed on both sides.

    
asked by Miguel Guzman 14.11.2017 в 07:25
source

1 answer

0

I found this on the net, I hope and it serves you.

#!/usr/bin/env python3
import fileinput

with fileinput.FileInput(filename, inplace=True, backup='.bak') as file:
    for line in file:
        print(line.replace(text_to_search, replacement_text), end='')
    
answered by 13.06.2018 в 21:03