python:File
python OCR Hand-written chinese
https://github.com/topics/chinese-character-recognition
https://github.com/chineseocr
https://github.com/breezedeus/cnocr
handwritten-text-recognition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | def getPreFile(prefixletter: str ,ok: bool ): """ 文件名添加后缀 :param prefixletter: :param ok: True 增加前缀,否则为删除 :return: """ try : nowfoloder = os.getcwd() curpath = os.path.join(nowfoloder,r "static" ) fiellist = os.listdir(curpath) n = 1 os.chdir(curpath) for i in fiellist: print ( "list" , i) if os.path.isfile(i): if ok = = True : newname = prefixletter + i os.rename(i, newname) else : newlen = len (prefixletter) newname = i[newlen:] os.rename(i, newname) n + = 1 except Exception as ex: print (ex) finally : pass |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | def getFile(prefixletter: str ,ok: bool ): """ 文件名添加后缀 :param prefixletter: :param ok: True 增加后缀,否则为删除 :return: """ try : nowfoloder = os.getcwd() curpath = os.path.join(nowfoloder,r "static" ) fiellist = os.listdir(curpath) n = 1 os.chdir(curpath) for i in fiellist: print ( "list" , i) if ok = = False : newname = i.split( "_" ) else : newname = i.split( "." ) print (newname[ 0 ] + '_' + prefixletter + "." + newname[ 1 ]) # if os.path.isfile(i): if ok = = True : os.rename(i, newname[ 0 ] + '_' + prefixletter + "." + newname[ 1 ]) else : os.rename(i, newname[ 0 ] + ".text" ) n + = 1 except Exception as ex: print (ex) finally : pass getFile( "d" , False ) """ try: nowfoloder=os.getcwd() fillist=os.listdir(nowfoloder) print(fillist) curpath=os.path.join(nowfoloder,r"static") print(curpath) os.chdir(curpath) for f in os.listdir(): print(f) if(not os.path.isdir("images")): os.mkdir("images") if (not os.path.isdir("test")): os.mkdir("test") for f in os.listdir(): print(f) if os.path.isdir("test"): curpath = os.path.join(nowfoloder, r"static") os.chdir(curpath) print(os.getcwd()) if os.path.isdir("test"): os.rmdir(os.path.join(curpath,"test")) except Exception as ex: print(ex) finally: pass """ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | """ PassWordLenException.py 单例 模式 python (类名) super java 继承可以使用 extends 和 implements 这两个关键字来实现继承 C++ :public 类名 C# :类名 可以重写父类方法 edit:geovindu,Geovin Du date:20230709 python 311 IDE:PyCharm 2023.1.2 """ import sys import os class PassWordLenException(Exception): """ 密码字符串长度自定义异常 """ def __init__( self ,strLen: int ,maxLen: int ,minLen: int ): """ :param strLen: 字符串长的长度 :param maxLen: 要求字符串的最长的长度 :param minLen: 要求字符串的最短的长度 """ super ().__init__( self ) self .__strLen = strLen self .__maxLen = maxLen self .__minLen = minLen @property def strLen( self ): return self .__strLen @strLen .setter def strLen( self ,strlen): self .__strLen = strlen @property def maxLen( self ): return self .__maxLen @maxLen .setter def maxLen( self ,maxlen): self .__maxLen = maxlen @property def minLen( self ): return self .__minLen @minLen .setter def minLen( self ,minlen): self .__minLen = minlen def __str__( self ): print (f "你输入的密码长度为{self.__strLen},最短的密码长度为{self.__minLen}最长的密度为:{self.__maxLen}" ) """ PassWord.py 单例 模式 python (类名) super java 继承可以使用 extends 和 implements 这两个关键字来实现继承 C++ :public 类名 C# :类名 可以重写父类方法 edit:geovindu,Geovin Du date:20230709 python 311 IDE:PyCharm 2023.1.2 """ import PassWordLenException class PassWord( object ): """ """ def __init__( self ): """ """ self .__password = ""; @property def passWord( self ): return self .__password; @passWord .setter def passWord( self ,password): if ( len (password)> = 6 ) and ( len (password)< = 12 ): self .__password = password else : raise PassWordLenException.PassWordLenException( len (password), 12 , 6 ) |
调用:
1 2 3 4 5 | try : p = PassWord.PassWord() p.passWord = "2333333" except PassWordLenException.PassWordLenException as e: print (e) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #备份文件 try : file = "" with open ( file , 'r' ) as rfp, open ( file , 'w' ) as wfp: #不用写关闭 ,读写一起操作 rstr = rfp.read() wfp.write(rstr) nowfoloder = os.getcwd() fillist = os.listdir(nowfoloder) print (fillist) curpath = os.path.join(nowfoloder,r "static" ) os.chdir(curpath) for f in os.listdir(): if os.path.isfile(f): t = os.path.splitext(f) #文件名和扩展名分开的元组 filename = t[ 0 ] fileexif = t[ 1 ] print (filename,fileexif) fstr = f.split( "." ) newname = fstr[ 0 ] + "备份" + ".text" print (newname) shutil.copy(f '{curpath}//{f}' ,f "{curpath}//{newname}" ) except Exception as e: print (e) |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2014-07-09 csharp: HttpWebRequest and HttpWebResponse