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

yipeiwu_com6年前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+Selenium+phantomjs实现网页模拟登录和截图功能(windows环境)

Python+Selenium+phantomjs实现网页模拟登录和截图功能(windows环境)

本文全部操作均在windows环境下 安装 Python Python是一种跨平台的计算机程序设计语言,它可以运行在Windows、Mac和各种Linux/Unix系统上。是一种面向对象...

使用Python实现分别输出每个数组

我就废话不多说了,直接上代码吧! a=[[1,2,3],[4,5][6,7]["a","b"",c"]] # i=0 # while i<len(a): # print(a...

pip matplotlib报错equired packages can not be built解决

pip安装matplotlib 在centos6.5 64bit上用pip安装matplotlib时候报错: * The following required packages ca...

tensorflow 输出权重到csv或txt的实例

实例如下所示: import numpy as np W_val, b_val = sess.run([weights_tensor, biases_tensor]) np.save...

解决pandas .to_excel不覆盖已有sheet的问题

直接to_excel会被覆盖,借助ExcelWriter可以实现写多个sheet。 from openpyxl import load_workbook excelWriter =...