Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8416011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:37:03+00:00 2026-06-10T01:37:03+00:00

I think the error is in the read function. It cannot read beyond the

  • 0

I think the error is in the read function. It cannot read beyond the special character in the image See repr output

I have using string.find() in python as follows:

indexOfClosedDoc = temp.find("</DOC>",indexOfOpenDoc)

However, when the string has text as below:

SUB
</DOC>

where SUB is a special character, temp.find cannot find the tag. Any suggestions on how to fix this

Example:

enter image description here

Code that causes it to fail:

handle = open("error.txt",'r');
temp = handle.read();
index = temp.find("</DOC>",0)
if(index == -1):
    print "Error"
    exit(1)

Put the image text in a text file and run the code

Here is repr of the temp variable for the text in the example. The text in eror.txt is everything from line 29722 in the image

' </P>\n\n'

NOTE: The read() function never read beyond SUB so finding is out of the question

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:37:05+00:00Added an answer on June 10, 2026 at 1:37 am

    The answer is to open the file using ‘rb’ mode. On Windows, opening the file with just ‘r’ will cause it to use the old DOS behaviour of stopping at 0x1A (a DOS EOF character). See also Line reading chokes on 0x1A

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think following code should generate an error: #include <iostream> #include <string> static void
I think i can´t find my (obvious stupid) error :-). Following SELECT statement on
I think I'm going blind, because I can't figure out where the syntax error
I keep getting a exc bad access error and I think it has something
I am getting this error for re-declaring saveorder() however, I don't think I am?!?
Hey guys I'm getting an error right around my second nested else, I think
For some reason, subversion is returning me error messages in what I think is
I have written a program that in the client section an error occures frequently,
Sometimes my script, that sends push notifications crashes with error: Warning: stream_socket_client() [function.stream-socket-client]: SSL
I have read-only access to a database that was set up for a third-party,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.