Original article: http://www.yiiframework.com/wiki/570/remove-byte-order-mark-bom-from-files-recursively/ The problem was that all my web applications ran normally on localhost, but on server the Greek characters (or any other no-english characters)
bat批量去除文件首行 set n=1 :starline for %%j in (*.txt) do ( :3 if exist D:\work\test\new_%n%.txt (set /a n+=1&goto 3) set file=%n%.txt for /f "skip=1 delims=" %%i in ('type "%file%"') do ( echo %%i >>D:\work\test\new_%n%.txt ) set
Python模糊查询本地文件夹去除文件后缀 import os,re def fuzzy_search(path): word= input('请输入要查询的内容:') for filename in os.listdir(path): #遍历指定文件夹 re_filename = re.findall('.\w+', str(filename)) #去除文件后缀名 if word in re_filename[0]: print(re_filename[0])
def stripFile(oldFile, newFile): '''remove the space or Tab or enter in a file, and output a new file in the same folder''' f = open(oldFile, 'r+', encoding='utf8') newf = open(newFile, 'w',encoding='utf8') for eachline in f.readlines(): newStr = eac
去除文件中重复的行 import os with open('db.txt','r',encoding='utf-8') as read_f,\ open('.db.txt.swap','w',encoding='utf-8') as write_f: s=set() for line in read_f: if line not in s: s.add(line) write_f.write(line) os.remove('db.txt') os.rename('.db.txt.swap',