On Tue, Feb 14, 2017 at 11:31 AM, Joaquin Alzola <joaquin.alz...@lebara.com> wrote: > >>with open(dirFichero,'r') as reader: > > for line in reader: > > print line >> >>the problem is that shown is : >>{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf810 >>{\fonttbl\f0\fswiss\fcharset0 Helvetica;} >>{\colortbl;\red255\green255\blue255;} >>{\*\expandedcolortbl;;} >>\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0 >>\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 >> >>\f0\fs24 \cf0 1l2m,1svo,1lme} >> >>INSTEAD of: >>1l2m,1svo,1lme >> >>How could I fix it? > > I do not know exactly what encoding rtf or the txt file has but you can use: > > with open(dirFichero,'r',encoding='utf-8') as reader:
This won't work. It will still display the rtf format coding, which the OP apparently does not want. -- boB -- https://mail.python.org/mailman/listinfo/python-list