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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:56:43+00:00 2026-06-03T16:56:43+00:00

aaa.txt: aszczx d as w ad python script: f = open(‘aaa.txt’,’r’) f.read() f.close() Console:

  • 0

aaa.txt:

aszczx
d
as
w
ad

python script:

f = open('aaa.txt','r')
f.read()
f.close()

Console:

C:\Python27>test.py

C:\Python27>

Why is it not displaying the contents of the file?

Thanks,

  • 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-03T16:56:44+00:00Added an answer on June 3, 2026 at 4:56 pm

    You are not displaying the contents of the file, just reading it.

    For instance you could do something like this:

    with open('aaa.txt') as infp:
        data = infp.read()
    
    print data # display data read 
    

    Using with will also close the file for your automatically

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

Sidebar

Related Questions

string line; ifstream myfile (aaa.txt); getline (myfile,line); system(curl.exe -b cookie.txt -d test=+line+ http://example.com );
I read in an array of strings such as: aaa bb ccccc ddd eeee
My code: #!/usr/bin/env python def Runaaall(aaa): Objects9(1.0, 2.0) def Objects9(aaa1, aaa2): If aaa2 !=
Say I have a bash script as follows while read $f; do cat $f
I have 2 simple tables: table a: id | txt ---+---- 0 | aaa
I have this test file. [root@localhost ~]# cat f.txt a aa MM bbb b
I have a file called one_to_many.txt. In the file is the data: a,aaa b,bbb
>cat testing.txt aaa bbb aaa ccc xxx yyy zzz ppp uuu vvv uuu ttt
When reading a txt file in windows by python, carriage characoters are lost in
A=(aaa bbb ccc) cat abc.txt | awk '{ print $1, ${A[$1]} }' I want

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.