May-28-2017, 08:22 AM
Hi, I'm a beginner at coding. I had a query regarding how an external text file (like an .txt file or even a .py file saved on the hard drive of my computer) can be read by Python. My intention is to command Python to read the data stored in that external file and print it. I am unsure of the syntax that should be used to do this.
I attempted to use f = open("filename","r") where filename was the location of the file in my hard drive (i.e. 'C:\User\ and so on). However, this did not work so I attempted to use import sys commands. But nothing seems to be working.
Can anyone help me out? Thanks!! :)
I attempted to use f = open("filename","r") where filename was the location of the file in my hard drive (i.e. 'C:\User\ and so on). However, this did not work so I attempted to use import sys commands. But nothing seems to be working.
Can anyone help me out? Thanks!! :)