You're also not writing a new line character after your value into the file, which may or may not cause a problem.
On Wed, Apr 6, 2016 at 1:32 AM, William Hermans <[email protected]> wrote: > *Here's some of my code. Hopefully you'll see something newbie-wrong that >> I've done. It's been a while since I have done file I/O, so it's likely >> that I have some syntax error(s).* >> > > So, I would reduce the code you have, at least in a test file, and use > only the absolute minimum code for printing a text string to a file. Then > of course double check to make sure it works. I would also remove the Str > conversion from the write() functional call, and make that an explicitly > defined string before the call to write(). The "call" Str(some numerical > value) also seems very odd to me. Usually with OOP languages you have > something akin to value.toString(value to convert), but again this is where > my lack of python BCL( base class library ) knowledge is going to leave me > at a disadvantage. > > On Tue, Apr 5, 2016 at 7:21 PM, Dennis Lee Bieber <[email protected]> > wrote: > >> On Tue, 5 Apr 2016 13:43:47 -0700 (PDT), John Baker >> <[email protected]> declaimed the >> following: >> >> >I want to store a little data on the eMMC from my Python code. My program >> >is not getting errors when I try to write a very short data file but it >> >doesn't actually seem to write it as I cannot read it back. I am using >> >f = open('MyFile.txt', w) >> > >> >> First problem -- the mode is a string... >> >> f = open("MyFile.txt", "w") >> >> >or >> >f = open('/home/debian/Desktop/MyFile.txt', w) >> > >> >or >> >f = open('MyFile.txt', r) >> > >> >or >> >f = open('/home/debian/Desktop/MyFile.txt', r) >> > >> >to open the file and am not getting any errors but Python is not finding >> >the file and I cannot find the file with a search from WinSCP. >> > >> Did you ever write anything to the file, and did you close the >> file? >> >> f.write("Some junk\n") >> f.close() >> >> >> The first open should create the file in whatever your current >> working >> directory is. Without connecting my BBB I can't confirm if the second is a >> valid path. >> >> And last -- how are you running it? SSH to a command line? >> >> -- >> Wulfraed Dennis Lee Bieber AF6VN >> [email protected] HTTP://wlfraed.home.netcom.com/ >> >> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to the Google Groups >> "BeagleBoard" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
