一、问题描述
环境信息:python版本:3.11,pycharm版本信息:PyCharm 2022.2.4 (Professional Edition)
代码如下:
if __name__ == '__main__':
time1 = datetime.now()
result = detectFaces(os.getcwd()+"\\images\\heying.jpg")
time2 = datetime.now()
print("耗时:" + str(time2 - time1))
if len(result) > 0:
print("有人存在!!---》人数为:" + str(len(result)))
else:
print('视频图像中无人!!')
drawFaces(os.getcwd()+"\\images\\", "heying.jpg")
# saveFaces(os.getcwd()+"\\images\\heying.jpg")
# drawSmiles('img/people.jpg') # 极其不准确
# drawEyes('people.jpg') # 有问题报错
pycharm console在输出中文是乱码,截图如下:
二、解决办法
1.File Encoding设置项目编码为GBK
2.文件模板设定python脚本为# -- coding: utf-8 --
3.重启pycharm,运行代码: