I tried to remove the first and last quote follow string[1:-1]. But it didn't work correctly! Here is my code:
def write_data_to_file(file_name, data):
f = open(file_name,'wb')
data_convert_str = dict()
data_remove_quotes =dict()
for index_line in range(1, number_lines +1)
data_convert_str[index_line] = repr(data_line])
data_remove_quotes[index_line] = data_convert_str[1:-1]
json.dump(data_remove_quotes[index_line], f)
f.write('\n')
f.close()
My data is a dict type: {'a' : 0.001, 'b' : 0.002}
that produce in my program.
And the result is: 'a' : 0.001, 'b' : 0.002
.
Please explain for me.
Thanks so much for help!