python - 删除 unicode 字符

标签 python file unicode

我想从 csv 文件中删除井号 (£)

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")

但是当我打印它时,内容根本没有改变。它返回相同的字符串。

最佳答案

更新您的内容

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

关于python - 删除 unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33038026/

相关文章:

c - 如何使用C程序检测文件中的特定字符串

python - Python 中 Latin-1 字符的短 Unicode\N{} 名称?

c++ - 如何强制 Visual Studio 使用 wmain 而不是 main

c# - 如何跟踪从 SQL Server 下载文件的进度?

unicode - 使用 Haskell 输出 UTF-8 编码的 ByteString

python - SQLite 性能基准测试——为什么 :memory: so slow. ..只有磁盘的 1.5 倍?

python - 基于其他列对数据框中的文本和计数进行标记

Python 3 : in a text file, 获取字符串在其出现的 y 行中出现的 x 次

python - 奇怪的 Python 导入错误

文件 Uri 方案和相关文件