当前位置: 首页 > 后端技术 > Python

Docker打包Python需要设置PYTHONUNBUFFERED吗?

时间:2023-03-26 15:49:11 Python

Python中的PYTHONUNBUFFERED环境变量有什么作用?下面是一个普通的dockerfile,里面有一行ENVPYTHONUNBUFFERED1,想都没想就加了,不知道不加会有什么后果!FROMpython:3.9-busterENVPYTHONUNBUFFERED1RUNmkdir/codeWORKDIR/codeCOPYrequirements.txt/code/RUN(/usr/local/bin/python-mpipinstall--upgradepip-ihttps://mirrors.aliyun.com/pypi/simple)&&(pipinstall-ihttps://mirrors.aliyun.com/pypi/simple-rrequirements.txt)COPY./code/阅读这篇文章:Python环境变量PYTHONUNBUFFERED对于3.7以上的版本:标准输出stdout和标准错误stderr在3.7版本中都是unbufferedChanged:stdout和stderr流的文本层现在是无缓冲的。只要是版本>3.7,就不需要添加PYTHONUNBUFFERED