osx - read error on Python in mac -


i'm new learner of python , use python 2.7 in mac ox 10.8.3.

today met problem python don't right data when executing file reading.

my input file include 2 website url this:

    www.google.com     www.facebook.com 

and python codes below, print input:

f = open("weblist.rtf","r") print f.read() f.close() 

but after run, output this:

    {\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf370     {\fonttbl\f0\fnil\fcharset134 stheitisc-medium;}     {\colortbl;\red255\green255\blue255;}     \paperw11900\paperh16840\margl1440\margr1440\vieww12200\viewh12840\viewkind1     \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural     \f0\b\fs36 \cf0 www.google.com\    www.facebook.com} 

how solve problem? has suggestion?

rtf files not simple text files (for example, windows .txt files), , there're specific headers rtf files.

you may have try on simple text file instead of other kind of text files.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -