zoukankan      html  css  js  c++  java
  • python 保存图片采用中文命名

    在批量重命名的时候,保存图片时,带有中文的字符会保存乱码。查阅资料后,找到解决方法。

    import cv2
    import os 
    import numpy as np
    
    path = 'E:\Personal\Desktop\rename\zaian\'
    names = os.listdir(path)
    
    for name in names:
        #img = cv2.imread(path + name)#
        #img=cv2.imdecode(np.fromfile(file_path,dtype=np.uint8),-1)#
        img = cv2.imdecode(np.fromfile(path + name , dtype=np.uint8),-1)
        x = name.split('-',2)
        newname = str(x[0]) +'-'+  x[2]
        #cv2.imwite('E:\Personal\Desktop\rename\w\'+newname,img)
        #cv2.imencode('.jpg',src)[1].tofile(filename)
        cv2.imencode('.png',img)[1].tofile('E:\Personal\Desktop\rename\w\'+newname)
  • 相关阅读:
    杀人蜂
    awk
    ggplot2
    非模式物种的注释
    org注释包
    NCB之taxonomy系列
    NCBI之gene系列
    notepad++查看二进制文件
    orthodb
    canu软件文献
  • 原文地址:https://www.cnblogs.com/j657521265/p/10912877.html
Copyright © 2011-2022 走看看