Q:

How to remove a particular character from a txt file?

Have a txt with contents : 
 {
 hello : 1,two:three,four:five,six:seven,
 }

how to remove the last  ,  in the above string ?
while using them as dictionaries for further. it cant be parsed because of the last delimiter. 
code : 
import json
d2=json.load(open(test.txt))

i cant change the source code. coz i am extracting data from a json file(json.dump) and creating a new json. is there any way of doing that other than dump/changing the source code

A:

This removes the last , in your string without the need of any further import's.
with open('test.txt', 'r') as f:
   s = f.read()
s = s[::-1].replace(',', '', 1)[::-1]

the output of s is then:
{
 hello : 1,two:three,four:five,six:seven
}

