import datetime def save2file(data,isR=1): # pass t= datetime.datetime.now() l=f"{'[R]' if isR else '[T]'} - {str(t)} --- {data.hex(' ')}\n" f=open('./rxlog.txt','a') f.write(l) f.close