Anay Bose February 2016

Python keeps showing the same old output

the problem is python keeps showing the same lines/strings in the output even though I have deleted one or more lines within a txt file; for example, the txt file "1.png.txt" contains the following lines:

extra for cooking the scallops
2 tbsp bottled mild or medium Thai
green curry paste
2 tbsp water
2 tsp light soy sauce

now, I have manually deleted the line "extra for cooking the scallops", but the output remains the same. It still shows the line "extra ... scallops" in the beginning. Can anyone please tell me how to get the correct output?

Here is the code:

import sys, os, string

with open("1.png.txt", 'r') as myfile:
    data = myfile.read()
    for n in data.split('\n'):
        print n

Answers


Brandon Rhodes February 2016

I always find in such cases that I am either failing to run “Save” successfully in my editor, or else am saving the file to a different location and so the old copy of the file that Python is using is staying the same.

But if you are using a particularly complex IDE, it is just conceivable that some kind of caching is going on? But my guess is one of my first two suggestions!

Post Status

Asked in February 2016
Viewed 2,194 times
Voted 13
Answered 1 times

Search




Leave an answer