1、创建pwd.py文件,内容如下
from os import *
from pwd import *
def get_username():
return getpwuid(getuid())[0]
2、将pwd.py 放入Python Lib中
“D:\software\miniconda\envs\maxkb” 为我虚拟环境的安装路径,将fcntl.py放入其中Lib目录下即可。再次运行py无误。
说明:Lib为python的默认标准库,在运行py时会被加载。