在python中自动创建多个文件对象

时间:2016-12-01 22:02:50

标签: python file python-3.x logging

我从多个调制解调器接收来自串行线路的数据包,调制解调器的ID连接到每个数据包端。对于每个调制解调器,我想创建一个用modemID命名的日志文件,(调制解调器的数量未确定)。如果日志文件已经打开,我想写入它

if logEnabled :
          filename =res[-3:] # last three bytes of the packets are the modemID   
          if not filename  in OpenedLogFile :  
                OpenedLogFile += filename   

                f= open(os.path.join(OUTPUT_DIR, filename), 'w',0)
                f.write(res + '\n')

          else:
               f.write(res + '\n')

0 个答案:

没有答案
相关问题