python - Some issue with Unicode encoding -


i trying open , parse json file using python script , write content json file after formatting want. source json file has character /" want replace blank. don't have issue in parsing or creating news file issue character not getting replaced blank. how do it. earlier have achieved same task there no such character in document time.

here code

doublequote = "\""   try:      destination = open("todayshtscrapeditemsoutput.json","w") # open json file    output except ioerror:     pass  open('todayshtscrapeditems.json') f: #load json file     data = json.load(f) print "file loaded" dataobj in data:     news in data[cnt]["body"]:         news = news.encode("utf-8")         if(news.find(doublequote) != -1): # if doublequotes found in first body tag         #   print "found double quote"             news.replace(doublequote,"")         if(news !=""):             my_news = my_news +" "+ news      destination.write("{\"body\":"+ "\""+my_news+"\"}"+"\n")     my_news = ""     cnt= cnt + 1 

here how file looks , quotes near red marked text should disappear

str.replace doesn't change original string.so need assign string news.

    if(news.find(doublequote) != -1): # if doublequotes found in first body tag     #   print "found double quote"         news = news.replace(doublequote,"") 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -