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 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() -
@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 three backticks start and end a code block,
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login