简体   繁体   中英

Remove unicode characters

I want to remove the pound sign ( £ ) from a csv file

f = open('menu.csv')
    content = f.read()
    content.decode("utf-8")
    print content
    content.decode("utf-8").replace(u"\u00a3", "*")

    content.decode("utf-8").replace(u"\u00a3", "*").encode("utf-8")

But when I print it, content doesn't change at all. It returns the same string.

更新您的content

content=content.decode("utf-8").replace(u"\u00a3", "*")

您不需要此编码/解码业务:

content=content.encode('utf-8').replace(u'£','*')
to print pound sign you should open file with encodigns flag ..

with open('data.csv', encoding='utf-8') as f:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM