最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Strange characters when they should not appear - Stack Overflow

programmeradmin2浏览0评论

I'm reading a file (.txt) and we have been told that the encoding is latin, and some friends are doing basicly the same as me but I'm not getting the same result.

This is the code:

file_path = '/sesion1/p1/ejerciciop1.txt'
with open(file_path, "r", encoding="latin-1") as f:
  lines = f.read().splitlines() 

datos = pd.DataFrame({"texto_original":lines})
print(datos)

I'm doing this in colab, and I'm suposed to get somethin like this: "Ellos est�n felices porque", but having this instead: "Ellos est�n felices porque". That extrange caracter is the problem. The encoding should be right as well, since we have been told is latin.

发布评论

评论列表(0)

  1. 暂无评论