Reading a text file
-
My main.py is:
main.py -- put your code here!
print ("In main...")
import setup_wifi
print ("WiFi setup...")
import ReadFileReadFile.py is:
print ("In ReadFile...")
file = open('02_250.txt', 'r')
file.close()Getting OSError Errno 2 ENOENT on file = open('02_250.txt', 'r')
I am returning to the SiPy after 6 months and I'm sure this worked back then.
-
@pmulvey three backticks start and end a code block,
-
@pmulvey said in Reading a text file:
02_250.txt
Got myself in a muddle having the file in the PC window of WinSCP and not on the device! Thanks for the reply. Oh, what are the special characters that signify a code block (black background) on the forum?
-
@pmulvey The error code just tells that the file does not exist. I made such a file as "/flash/02_250.txt", and successfully tried the three lines:
file = open('02_250.txt', 'r') content=file.readlines() file.close()