网络编程
位置:首页>> 网络编程>> Python编程>> 解决nohup重定向python输出到文件不成功的问题

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

作者:jodies  发布时间:2024-01-01 08:24:03 

标签:python,重定向,文件,nohup

原因是:


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()

来源:https://blog.csdn.net/jolinxia/article/details/51419161

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com