TypeError: not all arguments converted during string formatting
TypeError: not all arguments converted during string formatting
经过研究,我找到了一种无需锁定即可读取文件的解决方案。但是我无法从字符串/字符中的描述符解码接收到的缓冲区。这该怎么做?或者是否有另一种选择来读取文件而不阻塞,而不是使用字节?
filename = '/var/log/auth.log'
fopen = os.open(filename, os.O_NONBLOCK | os.O_RDONLY)
while True:
data = os.read(fopen, 1024)
if len(data) > 0:
#logger just for example in code is another function
logger.info('DATA: ',data)
#print data
我收到错误:
TypeError: not all arguments converted during string formatting
默认情况下,您正在传递一个值 data
to be formatted into the message, but your message doesn't contain a field for this to be substituted. It follows the printf-style string formatting syntax。
logger.info('DATA: %s', data)
经过研究,我找到了一种无需锁定即可读取文件的解决方案。但是我无法从字符串/字符中的描述符解码接收到的缓冲区。这该怎么做?或者是否有另一种选择来读取文件而不阻塞,而不是使用字节?
filename = '/var/log/auth.log'
fopen = os.open(filename, os.O_NONBLOCK | os.O_RDONLY)
while True:
data = os.read(fopen, 1024)
if len(data) > 0:
#logger just for example in code is another function
logger.info('DATA: ',data)
#print data
我收到错误:
TypeError: not all arguments converted during string formatting
默认情况下,您正在传递一个值 data
to be formatted into the message, but your message doesn't contain a field for this to be substituted. It follows the printf-style string formatting syntax。
logger.info('DATA: %s', data)