₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,328,757 members, 8,437,209 topics. Date: Wednesday, 01 July 2026 at 01:26 PM

Toggle theme

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

Nairaland ForumScience/TechnologyProgrammingPython Gurus In The House Help With This Questions (1295 Views)

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()
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.
Re: Python Gurus In The House Help With This Questions by Nobody:
T
Re: Python Gurus In The House Help With This Questions by Excallibur(m): 8:15am On Jul 05, 2022
Try print(lines)
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.
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

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.
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 Reply

Gurus In The House: Macbook Or Windows, Which Is Best For Programming ?Python Gurus Please Help Me With This Code.Gurus In The House, What Do Backend Developers Do?234

150k Per Month. Laravel Dev WantedHi Guys Please Which Hp Laptop Is Good For ProgramingHelp Me Learn The Basics