Operating environment
Raspberry Pi2 + raspbian
In the case of the following code in python code, if the srcpath file is not found, return "" will be displayed.
def read_fileModificationDate_sendText():
srcpath="/home/pi/BYOP/send.txt"
if os.path.isfile(srcpath) == False:
return ""
mddt = time.ctime(os.path.getmtime(srcpath))
parsed = time.strptime(mddt)
yyyymmdd = time.strftime("%Y%m%d", parsed)
return yyyymmdd
The value received by ~~ return "" seems to be a NoneType object, and the method of determining it was found in the link below. ~~ (Corrected below)
The None Type verdict was found at the link below.
http://python.g.hatena.ne.jp/oneshotlife_tom/20121127/1354009706
If you want to determine if it is None in Python, you can use the == operator.
>>> a = None
>>> if a == None:
... print "None"
...
None
After reviewing the code based on @ shiracamus's comment, it seems that the following function return
is NoneType.
def read_sendtext():
# debug_outputDebugString("read_sendtext","Line52 > start")
srcpath="/home/pi/BYOP/send.txt"
if os.path.isfile(srcpath) == False:
# debug_outputDebugString("read_sendtext","Line55 > send.txt not found");
return
rdfd = open(srcpath)
lines = rdfd.readlines()
rdfd.close()
# debug_outputDebugString("read_sendtext","Line80 > lines:" + str(lines))
return lines
Recommended Posts