proc.communicate()的输出不会在django python中格式化换行符

proc.communicate()的输出不会在django python中格式化换行符,python,django,django-views,popen,Python,Django,Django Views,Popen,我有一个子流程使用Communication获取输出并将其保存到我的数据库: p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE) syncoutput = p.communicate() check.log = syncoutput 这一切都很好,但Communication的输出如下所示: ('sending incremental file list\n\nsent 89 bytes rec

我有一个子流程使用Communication获取输出并将其保存到我的数据库:

  p = Popen([str(pre_sync), '-avu', str(src), str(dest)], stdout=PIPE)
  syncoutput = p.communicate()
  check.log = syncoutput
这一切都很好,但Communication的输出如下所示:

('sending incremental file list\n\nsent 89 bytes  received 13 bytes  204.00 bytes/sec\ntotal size is 25  speedup is 0.25\n', None)
全部在一行中并插入“\n”。有没有办法让它在新的一行中打印每一行?提前谢谢

syncoutput,sync_error = p.communicate()
print(syncoutput)
返回一个2元组,由stdout和stderr的输出组成。打印2元组时,您会看到
\n
字符。打印字符串(新的
syncoutput
)时,您将得到格式化文本

返回一个2元组,由stdout和stderr的输出组成。打印2元组时,您会看到
\n
字符。当您打印字符串(新的
syncoutput
)时,您将获得格式化文本。

@dura,请务必接受此答案(检查A左侧的复选标记形状图标)-“谢谢很便宜,但接受事宜”是SO基本礼仪的一部分!)@杜拉,一定要接受这个答案(勾选A左边的复选标记形状的图标)——“谢谢很便宜,但接受这件事”是SO基本礼仪的一部分