解决nohup重定向python输出到文件不成功的问题

yipeiwu_com5年前Python基础

原因是:

It looks like you need to flush stdout periodically (e.g. sys.stdout.flush()). In my testing Python doesn't automatically do this even with print until the program exits.
You can run Python with the -u flag to avoid output buffering

所以,

解决办法之一:加-u

nohup python -u Bilstm-My-Exp-Char.py --training 1 --char_base 1 --window 5 --rnn_active relu --data_root ../../wangzhen/bilstm/ --load_embed 1 --model_pkl mdl5-15-14-30 > 5.txt 2>&1 &

解决办法之二: sys.stdout.flush()

以上这篇解决nohup重定向python输出到文件不成功的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

下载糗事百科的内容_python版

复制代码 代码如下:#coding:utf-8 import urllib.request import xml.dom.minidom import sqlite3 import th...

Flask之pipenv虚拟环境的实现

在 python 开发过程中,导入第三方库是最常见的操作,但是如果咋在本机自带 python 环境下安装第三方包。 就会造成库的冗余,比如某个项目只需要部分第三方库,但是其他项目又需要其...

使用Python发送各种形式的邮件的方法汇总

我们平时需要使用 Python 发送各类邮件,这个需求怎么来实现?答案其实很简单,smtplib 和 email 库可以帮忙实现这个需求。smtplib 和 email 的组合可以用来发...

Python中sort和sorted函数代码解析

本文研究的主要是Python中sort和sorted函数的相关内容,具体如下。 一、sort函数 sort函数是序列的内部函数 函数原型: L.sort(cmp=None, key=No...

python中将字典形式的数据循环插入Excel

python中将字典形式的数据循环插入Excel

1.我们看到字典形式的数据如下所示 list=[["2891-1", "D"],["2892-1", "D"],["2896-1", "B"],["2913-1", 0],["291...