Doubt with files

boB Stepp robertvstepp at gmail.com
Tue Feb 14 12:40:14 EST 2017


On Tue, Feb 14, 2017 at 11:31 AM, Joaquin Alzola
<Joaquin.Alzola at 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



More information about the Python-list mailing list