Opening and reading from a text file using python on Prime G2
|
05-30-2023, 09:03 PM
Post: #2
|
|||
|
|||
RE: Opening and reading from a text file using python on Prime G2
(05-29-2023 07:00 AM)Farlanw Wrote: Hi, am so far unable to open a one-line text file created in notes -get a system error .That seems to be quite a challenge. First: you need to properly address the "Note". In this case: fpath=open("../testxt.hpnote") Second: readline isn't a function, but a method of the object "fpath" that you've created with the "open" function. "open" is an alias for various IO classes. Therefore you need to apply "readline" as a "method" of this object. I store it in a list for further processing, right away. line = list(fpath.readline()) now you have a list of garbage, of which you can extract your text with: line = "".join(line[0:len(line):2]) result is a string with an arbitrary amount of additional random characters. Unfortunately MicroPython doesn't have the string method "decode" may still not be what you want, but perhaps usable somehow. HTH Günter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Opening and reading from a text file using python on Prime G2 - Farlanw - 05-29-2023, 07:00 AM
RE: Opening and reading from a text file using python on Prime G2 - Guenter Schink - 05-30-2023 09:03 PM
|
User(s) browsing this thread: 1 Guest(s)