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 8008641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:12:08+00:00 2026-06-04T18:12:08+00:00

Possible Duplicate: Handling \r\n vs \n newlines in python on Mac vs Windows I’m

  • 0

Possible Duplicate:
Handling \r\n vs \n newlines in python on Mac vs Windows

I’m a little bit confused by something, and I’m wondering if this is a python thing. I have a text file that uses Windows line endings (“\r\n”), but if I iterate through some of the lines in the file, store them in a list, and print out the string representation of the list to the console, it shows “\n” line endings. Am I missing something?

  • 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-04T18:12:10+00:00Added an answer on June 4, 2026 at 6:12 pm

    Yes, it’s a python thing; by default open() opens files in text mode, where line endings are translated depending on what platform your code is running on. You’ll have set newline='' in the open() call to ask for line endings to be passed through unaltered.

    Python 2’s standard open() function doesn’t support this option, and only opening in binary mode would prevent the translation, but you can use the Python 3 behaviour by using io.open() instead.

    From the documentation on open:

    newline controls how universal newlines mode works (it only applies to text mode).

    […]

    • When reading input from the stream, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newlines mode is enabled, but line endings are returned to the caller untranslated.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: oracle PL/SQL: sort rows I run this query: Select a.product, sum( case
Possible Duplicate: Show line number in exception handling Can someone please tell me how
Possible Duplicate: check what files are open in Python Hello, Is it possible to
Possible Duplicate: Handling exceptions from Java ExecutorService tasks I use the ExecutorService from Java
Possible Duplicate: Error handling in C code What return value should you use for
Possible Duplicate: Using global exception handling with “setUncaughtExceptionHandler” and “Toast” I have implemented UncaughtExceptionHandler
Possible Duplicate: When do you use the “this” keyword? Hello, I understand that the
Possible Duplicate: Handling a Click for all controls on a Form I have a
Possible Duplicate: Unload a module in Python After importing Numpy, lets say I want
Possible Duplicate: how to use foursquare API in android application? This is a question

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.