A Python String Replace Problem
#1
I use Python urllib.urlopen, and get the following web page code:
Code:
http:\u002F\u002Fm.wsj.net\u002Fvideo\u002F20091222\u002F122209ghosnturn\u00
2F122209ghosnturn_512x288.jpg
I want to replace "\u002F" with "/"
I tried
Code:
str.replace("\u002F", "/")#Failed
str.replace("\\u002F", "/")#Failed
str.replace(u"\u002F", "/")#Failed
str.replace(u"\\u002F", "/")#Failed
How can I replace "\u002F" with "/"?
Thanks a lot!Nerd
Reply
#2
Try:

PHP Code:
str u"http:\u002F\u002Fm.wsj.net\u002Fvideo\u002F20091222\u002F122209ghosnturn\u002F122209ghosnturn_512x288.jpg"
print str.decode("utf8"
Reply

Logout Mark Read Team Forum Stats Members Help
A Python String Replace Problem0