for anyone watching way in the future, windows automatically hides file extensions (such as .txt) by default. You can change this by opening any folder, clicking on the "View" tab, and checking the "File name extensions" box.
I just LOL'd when Tim wrote "easy" at the end but didn't hit enter to leave the EOF (end of file) at the bottom, and a newline character after "easy". As a teenager I developed a habit of always having a blank line at the bottom, and this video is why. Tim's tutorial is good though, he demonstrates how to handle any scenario. Next lesson: why to never use whitespace characters on your files ;-)
I keep getting an error: FileNotFoundError: [Errno 2] No such file or directory: 'file.txt' but I checked the files place and the name and it should be al fine. are there other reasons why this doesn't work?
Do you have a video to show how to path join with files (txt in my case)? If so could you please show me/anyone else that needs this video? Thank you for this video as well.
I just tested that out a few different ways. It looks like file.read() returns one large string while the file.readlines() returns each line as a separate string, which makes it easier to manipulate into a list.
You can also do it like this file = open('name.txt', 'r') data = file.read() ans = data.split( ) print(ans) It should give you the list without adding the in it
@@The.Radiance Cannot really remember what I was talking about... But if it's a list you should be able to do a quick for loop and then print the string individually If you are sure the value will only be 1 you can just print ans[0]
This is outdated, I recommend watching the 'Python Tutorial: How to Read and Write Text Files' tutorial, from Essential Engineering. His code works fine
Found your channel yesterday and subscribed... just starting my python journey so I am a bit late to the party lol , been at it a few weeks now and find your style of teaching is helping things stick so thank you. Subbed :)
So why the hell do you start a tutorial in python 3.6 and than in the middle you switch to 3.5 WITH NO WARNING??? Just lost HOURS because I thought I went crazy, had the same code but it wasn't working....
I honestly felt like giving up on python, you've made it so easy to understand!
Did you give up?
for anyone watching way in the future, windows automatically hides file extensions (such as .txt) by default. You can change this by opening any folder, clicking on the "View" tab, and checking the "File name extensions" box.
Omg you saved me!! Thank u❤️
I've been on this for two days😭✨
Your are really awesome ! I had a hard time digesting these in school curriculum and you managed to enlighten me in minutes. Thank you so much.
Hey all i'm using python 3.9 and this no longer works. Use the following instead.
file = open('file.txt', 'r')
print(file.read())
file.close()
this is so easy to understand and short at the same time! Thank you so much !
you're the best!!! thanks
read in 1st attempt, thank you master.
now this is epic!!
Oh Yeah Yeah
What do you mean
Thanks Tim! helped me with the capture the flag game I was playing.
I just LOL'd when Tim wrote "easy" at the end but didn't hit enter to leave the EOF (end of file) at the bottom, and a newline character after "easy". As a teenager I developed a habit of always having a blank line at the bottom, and this video is why. Tim's tutorial is good though, he demonstrates how to handle any scenario. Next lesson: why to never use whitespace characters on your files ;-)
I don't get this
"r" argument is not necessary in the open() function because r is the default option.
Thank you 🤩🙏🏼
I keep getting an error: FileNotFoundError: [Errno 2] No such file or directory: 'file.txt' but I checked the files place and the name and it should be al fine. are there other reasons why this doesn't work?
Recommend using the "with" key to open and write.
well thx man for the great introduction into learning how to code.
my internet !!!! it keeps buffering T^T..... i have to watch in 360p
after I put -1 first time it doesn't work anymore :( (3.8 version)
Perfect for beginners like me! Ty!
I suggest you use
file .close()
on line 3 so you avoid over loading your ram.
Do you have a video to show how to path join with files (txt in my case)? If so could you please show me/anyone else that needs this video? Thank you for this video as well.
Great Video!
I'm putting together a quiz for an assignment, and it requires the use of a text file.
1:02 It's not random
It's the description of your series
Just awesome
Nice video
Watched at 2x
Meet you in next one
Awesome !
can someone give me an example of what this could be used for when working on a project?
it's always saying No such file when I made the file already and I made it in Quick access
line is just your word choice for item correct?
I used rstrip('
')
He didn't "file.close()" which means his ram will fill up really quickly.
Looks like it auto-closes for me. Each time I used the file.readlines() I had to reopen the file if I wanted to call it in another instance.
@@isaiah7310 It doesn't auto-close using the method he used to open. You should use "with open("file.txt", "r").
@@tinpot1978 Thanks
file.read() is a lot easier
I just tested that out a few different ways. It looks like file.read() returns one large string while the file.readlines() returns each line as a separate string, which makes it easier to manipulate into a list.
I thought append meant add
I saved both textfile & idle file in same folder,
even after that it shows me file not found😐
having the same issue. Could you solve it?
@@Polshani_keshf_et why not post the code here.... i can help
how to do math with files?
gold
this was an terrible jump from vid 12 to 13 , feels like a new world..
not working on thonny. someone help please
Newer version probably.
iluvu
Great Video.
Thank You.
"random words"
ऐप का क्या नाम है
huh...
this is what i felt
your code is wrong lol and outdated
Instead of making unhelpful comments, how about telling us why it's wrong and outdated?
can you tell me please becuase mine is not working
the code does work guys.. are you putting [ ] when you start the newList or you putting () ?
you have to put [ ] not ()
@@prettylou2010 Works for me, P3.8
I'm P 3.9 and it's working fine
which mode can i use to read as well as write in a text file. this to save and access data of a game
You can also do it like this
file = open('name.txt', 'r')
data = file.read()
ans = data.split(
)
print(ans)
It should give you the list without adding the
in it
How do you get rid of the [" "] around the text? my output is this:
['hello world']
@@The.Radiance Cannot really remember what I was talking about... But if it's a list you should be able to do a quick for loop and then print the string individually
If you are sure the value will only be 1 you can just print ans[0]
You're so helpful!! Thank you!!
This is outdated, I recommend watching the 'Python Tutorial: How to Read and Write Text Files' tutorial, from Essential Engineering. His code works fine
Can we create 5 folders {hello,tim, python,learning,easy} reading from text file??
When using linux python always places my text file in /home/myUsername directory instead of next to the .py file, why is this?
Only needed the first 1;23 seconds of the video but thank ya very much mister
I am working on a project right now and you helped me a lot! Thank you
"name read is not defined".
great video Tim!! Just what I needed!
Found your channel yesterday and subscribed... just starting my python journey so I am a bit late to the party lol , been at it a few weeks now and find your style of teaching is helping things stick so thank you. Subbed :)
you were earlier than the next person which is me .....hope you still going and for sure you good at it now
So
= 1 character? Did not expect that hehe
So why the hell do you start a tutorial in python 3.6 and than in the middle you switch to 3.5 WITH NO WARNING??? Just lost HOURS because I thought I went crazy, had the same code but it wasn't working....
What code did I use that works in 3.6 that doesn’t work In 3.5 or other way around