3

I want to replace the number sign (#) with a character similar to that called music sharp sign (♯). I tried the following line but didnt work.

res['n'].replace('#', '♯')

I also tried these and also didnt work fine.

res['n'].replace('#', u'♯')
res['n'].replace('#', '\xe2')

Anyone got any idea about the situation?

Sina
  • 183
  • 1
  • 10

3 Answers3

2
res="He##o"
res=res.replace("#","♯")
print res

o/t He♯♯o
Prakash Kuma
  • 722
  • 1
  • 6
  • 11
0
import re
text = ' '
re.sub(' ', '\x00', text)

Why not you use this?

nEO
  • 5,305
  • 3
  • 21
  • 25
0

Replace returns the changed string, strings cannot be changed themselves. Try

res['n'] = res['n'].replace('#', '♯')
RemcoGerlich
  • 30,470
  • 6
  • 61
  • 79