ConfusedLuigi
ConfusedLuigi

Reputation: 87

Why do I get this output? (Python)

numbers.txt has 2 lines: 123 and 456

When I run this:

list = open('numbers.txt').read().splitlines()
print list

It gives me this output:

['{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf340', '{\fonttbl\f0\fswiss\fcharset0 ArialMT;}', '{\colortbl;\red255\green255\blue255;}', '\paperw11900\paperh16840\margl1440\margr1440\vieww8860\viewh6060\viewkind0', '\deftab720', '\pard\pardeftab720\sl480\sa144\partightenfactor0', '', '\f0\fs32 \cf0 \expnd0\expndtw0\kerning0', '123\', '456}']

Upvotes: 2

Views: 1589

Answers (1)

le_camerone
le_camerone

Reputation: 630

It looks like this is an rtf file. This appears to be the first line which has a lot of formatting of text, font size, etc. You can delete the first line with the following:

del list[0]

Otherwise you could just select the lines you want by referencing their index.

Upvotes: 1

Related Questions