Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,744 members, 7,817,054 topics. Date: Saturday, 04 May 2024 at 01:23 AM

Python Gurus In The House Help With This Questions - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Gurus In The House Help With This Questions (863 Views)

Gurus In The House: Macbook Or Windows, Which Is Best For Programming ? / Python Gurus Please Help Me With This Code. / New To Python, Gurus Please Help Solve These Challenges. Thanks. (2) (3) (4)

(1) (Reply) (Go Down)

Python Gurus In The House Help With This Questions by Nobody: 6:27am On Jul 05, 2022
HOW DO I CREATE PYTHON SCRIPT TO OPEN FILES SAVED AS TEXT FILE AND DISPLAY THE TEXT LINES??
Re: Python Gurus In The House Help With This Questions by Golan007: 6:36am On Jul 05, 2022
with open('readText.txt') as f:
lines = f.readlines()

1 Like

Re: Python Gurus In The House Help With This Questions by Nobody: 7:47am On Jul 05, 2022
Golan007:
with open('readText.txt') as f:
lines = f.readlines()

The filename will be in the readtext space right? E.g I saved my document file scantext.tx
Which part of the pycharm do I type that command? In the terminal or the pycharm window?
Re: Python Gurus In The House Help With This Questions by Golan007: 7:56am On Jul 05, 2022
bruno10000:


The filename will be in the readtext space right? E.g I saved my document file scantext.tx
Which part of the pycharm do I type that command? In the terminal or the pycharm window?

Please do it in your pycharm window.

1 Like

Re: Python Gurus In The House Help With This Questions by Nobody: 8:08am On Jul 05, 2022
T
Re: Python Gurus In The House Help With This Questions by Excallibur(m): 8:15am On Jul 05, 2022
Try print(lines)

1 Like 1 Share

Re: Python Gurus In The House Help With This Questions by Golan007: 9:22am On Jul 05, 2022
bruno10000:
Golan007

I just ran the command but in getting a blank terminal window


Place this after:


Print(lines)
Re: Python Gurus In The House Help With This Questions by Nobody: 9:49am On Jul 07, 2022
Golan007 please how do I update a script and then print corresponding information in two different text files

Excalibur
Re: Python Gurus In The House Help With This Questions by Golan007: 11:58am On Jul 07, 2022
bruno10000:
Golan007 please how do I update a script and then print corresponding information in two different text files

Excalibur

With open('nono.txt', 'r') as f:
lines = f.readlines()
for line on lines:
print(line)

Updated_lines = ["", "I don't care if your name is Jojo\n", "Just dance for me"]


with open('nono.txt', 'a') as Ap:
new_updates = Ap.writelines('\n'.join(Updated_lines))
print(new_updates)
Re: Python Gurus In The House Help With This Questions by Golan007: 12:01pm On Jul 07, 2022
You need something like

with open('first.txt', 'r') as firstfile, open('second.txt', 'a') as secondfile:
for line in firstfile:
secondfile.write(line)
Re: Python Gurus In The House Help With This Questions by Golan007: 12:01pm On Jul 07, 2022
If not exact, you need to figure it out.

That's what makes you better.
Re: Python Gurus In The House Help With This Questions by Nobody: 12:20pm On Jul 07, 2022
Okay, thanks sir. I'll put this codes to use now and try to work my way around the whole thing.
Re: Python Gurus In The House Help With This Questions by jesmond3945: 12:29pm On Jul 07, 2022
bruno10000:
HOW DO I CREATE PYTHON SCRIPT TO OPEN FILES SAVED AS TEXT FILE AND DISPLAY THE TEXT LINES??
lol. Google can help you.

1 Like

Re: Python Gurus In The House Help With This Questions by Nobody: 12:49pm On Jul 07, 2022
jesmond3945:
lol. Google can help you.

It's so hard coming by the ans on google
Re: Python Gurus In The House Help With This Questions by jesmond3945: 1:20pm On Jul 07, 2022
bruno10000:


It's so hard coming by the ans on google

1 Like

Re: Python Gurus In The House Help With This Questions by Nobody: 10:08am On Jul 15, 2022
[quote author=jesmond3945 post=114506754][/quote]

Golan007

Thanks guys, your contributions to my test ...was really helpful. Please can you guys suggest any video link for me to download in order to understand using the with statement for files, networking etc

Or any video link to understand python statements more at this level because I have so much assignment coming up

Thanks y'all
Re: Python Gurus In The House Help With This Questions by jbreezy: 10:13am On Jul 15, 2022
Just go and read Python Crash Course from the beginning to the end. Everything you need to know as a python beginner is provided inside that gem.

1 Like

Re: Python Gurus In The House Help With This Questions by Golan007: 10:21am On Jul 15, 2022
bruno10000:


Golan007

Thanks guys, your contributions to my test ...was really helpful. Please can you guys suggest any video link for me to download in order to understand using the with statement for files, networking etc

Or any video link to understand python statements more at this level because I have so much assignment coming up

Thanks y'all


https://www.youtube.com/watch?v=Uh2ebFW8OYM
Re: Python Gurus In The House Help With This Questions by Nobody: 11:37am On Jul 15, 2022

1 Like

(1) (Reply)

Flutter D/egl_emulation( 6380): App_time_stats [solved] / Visual Java Compiler / Business Process Execution Language (Bpel) Help

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.