开发者

Strip Trademark Symbol from string Python

开发者 https://www.devze.com 2023-04-11 13:02 出处:网络
I\'m trying to prep some data for a designer. I\'m pulling data out of SQL Server with pythonon a Windows machine (not sure if OS is important). How would I make the string \'Official Trademark™\' =

I'm trying to prep some data for a designer. I'm pulling data out of SQL Server with python on a Windows machine (not sure if OS is important). How would I make the string 'Official Trademark™' = 'Official Trademark'? Also, any further information/reading on unicode or the pertinent subject matter would help me become a little more independent. Thanks for any help!

Edited:

Perhaps I should have included some code. I'm now getting this error during run time: 'UnicodeDecodeError: 'ascii' codec can't decode byte 0x99 in position 2:ordinal not in range(128).' Here is my code:

row.note = 'TM™ Data\n'
t = row.no开发者_如何学Cte
t = t.rstrip(os.linesep).lstrip(os.linesep)
t = t.replace(u"\u2122",'')


The trademark symbol is Unicode character U+2122, or in Python notation u"\u2122".

Just do a search and replace:

'string'.replace(u"\u2122", '')


>>> 'Official Trademark™'.strip('™')
'Official Trademark'
>>> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号