看世界
 
昨日:篇  今日:篇   总帖:篇   会员:
今日:0
文章:0
今日:0
文章:6
IT
今日:0
文章:57
今日:0    总帖:66
admin
38
# -*- coding: utf-8 -*- import os import os.path from PIL import Image import shutil list1 = [] def get_py(path,list1): fileList = os.listdir(path) # 获取path目录下所有文件 for filename in fileList: pathTmp = os.path.join(path,filename) # 获取path与filename组合后的路径 if os.path.isdir(pathTmp): # 如果是目录 get_py(pathTmp,list1) # 则递归查找 elif filename[-4:] == '.jpg':# 如果不是目录,则比较后缀名 list1.append(pathTmp) # path = 'D:\web\PHPnow-1.5.6\\vhosts\img.pictutu.com\\img' path = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\list\1' path = 'z:\\100' # path = 'z:\\TEST' get_py(path,list1) print('在%s目录及其子目录下找到%d个jpg文件,分别为:' % ( path,len(list1))) for filename in list1: # print(path) img = Image.open(filename) w = float(img.size[0]) h = float(img.size[1]) print w print h b= w/h if b > 1.25 : path1 = "z:\\new\\1\\" print (b) # path1 = "z:\\N123\\1\\" path1 = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\list\list1' shutil.copy(filename, path1) # print 'type1:' + str(len(filename)) elif 0.9< b<=1.25: # print '正方形图片' # path2 = "z:\\N123\\2\\" # path2 = "z:\\new\\2\\" path2 = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\list\list2' shutil.copy(filename, path2) # print'type2:' + str(len(filename)) else: # print "竖型图片" # path3 = "z:\\new\\3\\" # path3 = "z:\\N123\\3\\" path3 = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\list\list3' shutil.copy(filename, path3)
IT 0 0 95天前
admin
47
# -*- coding: utf-8 -*- __author__ = 'Administrator' import os import re import sys path = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\1' newpath = r'D:\web\PHPnow-1.5.6\vhosts\img.pictutu.com\img\new' def renameall(): fileList = os.listdir(path) # 待修改文件夹 print("修改前:"+str(fileList)) #输出文件夹中包含的文件 currentpath = os.getcwd() #得到进程当前工作目录 os.chdir(path) #将当前工作目录修改为待修改文件夹的位置 num = 1 for fileName in fileList: pat = ".+?\.(JPG|jpg)" # 匹配文件名正则表达式 pattern = re.findall(pat,fileName) #进行匹配 # os.rename(fileName,('a' + str(num)+'.'+'jpg')) os.rename(fileName, (str(num) + '.' + 'jpg')) #文件重新命名 num = num+1 print("---------------------------------------------------") os.chdir(currentpath) # 改回程序运行前的工作目录 sys.stdin.flush() #刷新 renameall()"D:\Program Files (x86)\Anaconda2\python.exe" C:/Users/Administrator/PycharmProjects/RE_NAME_P3.py1. 修改为当前 文件夹2. 可能需要 中间名 中转
IT 0 0 95天前
admin
52
[Image]
IT 0 0 95天前
admin
42
# -*- coding: utf-8 -*- import os import os.path from PIL import Image import shutil list1 = [] def get_py(path,list1): fileList = os.listdir(path) # 获取path目录下所有文件 for filename in fileList: pathTmp = os.path.join(path,filename) # 获取path与filename组合后的路径 if os.path.isdir(pathTmp): # 如果是目录 get_py(pathTmp,list1) # 则递归查找 elif filename[-4:] == '.jpg':# 如果不是目录,则比较后缀名 list1.append(pathTmp) path = 'z:\\100' # path = input('请输入路径:').strip() get_py(path,list1) print('在%s目录及其子目录下找到%d个jpg文件,分别为:' % ( path,len(list1))) for filename in list1: print(filename) img = Image.open(filename) w = img.size[0] h = img.size[1] if w > h: path1 = "z:\\new\\1\\" shutil.copy(filename, path1) # print 'type1:' + str(len(filename)) elif w == h: # print '正方形图片' path2 = "z:\\new\\2\\" shutil.copy(filename, path2) # print'type2:' + str(len(filename)) else : # print "竖型图片" path3 = "z:\\new\\3\\" shutil.copy(filename, path3) print'type3:' + str(len(filename))
IT 0 0 95天前
admin
67
# coding: utf8 from PIL import Image import os, sys import shutil path = "z:\\new\\" filename = 2 img = Image.open("z:\\{}.gif ".format(filename)) w = img.size[0] h = img.size[1] if w > h: print "横型图片" path1 = "z:\\new\\1\\" shutil.copy("z:\\{}.jpg".format(filename),path1) elif w == h: print '正方形图片' path2 = "z:\\new\\2\\" shutil.copy("z:\\{}.gif ".format(filename),path2) else: print "竖型图片" path3 = "z:\\new\\3\\" shutil.copy("z:\\{}.PNG|.jpg ".format(filename),path3)
IT 0 0 96天前
admin
138
ip代理   
# -*- coding: UTF-8 -*-import requests # proxies = { "http": "http://125.70.13.77:8080" }# proxies = { "http": "http://122.235.175.128:8118"} # proxies = { "http": "http://120.77.249.46:8080" } x '61.135.217.7', '80'proxies = { "http": "http://61.135.217.7:80" }res = requests.get("http://www.882667.com/",proxies=proxies)# res = requests.get("http://www.baidu.com", proxies=proxies)print resprint(res.text)
IT 0 0 96天前
admin
47
# -*- coding: UTF-8 -*- import os, sys city = 'cd' path = "z:\\down\\test11\\" + city txtpath = 'filename' isExists=os.path.exists(path) if not os.path.exists(path): print '目录不存在' os.makedirs(path.decode('utf-8')) print '文件夹:' + path print "当前进程工作目录 : %s" % os.getcwd() else: print '目录已经存在....' print '文件夹:' + path print "当前进程工作目录 : %s" % os.getcwd() with open(path + "\\{}.txt".format(txtpath), "a") as f: f.write('456') f.close()目录已经存在.... 文件夹:z:\down\test11\cd 当前进程工作目录 : C:\Users\Administrator为filename.txt 写入'456'
IT 0 0 96天前
admin
32
# -*- coding: utf-8 -*- import os # path = 'Z:\\news\\001' # if not os.path.exists(path): # os.makedirs(path) path = 'Z:\\news\\news3' isExists=os.path.exists(path) if not os.path.exists(path): print '目录不存在' os.makedirs(path.decode('utf-8')) print path+'目录创建成功!' else: print '目录已经存在....'
IT 0 0 96天前
admin
30
['青羊','14','https://www.anjuke.com/chengdu/cm/qingyang/'],['锦江','11','https://www.anjuke.com/chengdu/cm/jinjiang/'],['金牛','11','https://www.anjuke.com/chengdu/cm/jinniu/'],['武侯','15','https://www.anjuke.com/chengdu/cm/wuhou/'],['成华','12','https://www.anjuke.com/chengdu/cm/chenghua/'],['高新区','9','https://www.anjuke.com/chengdu/cm/gaoxin/'],['天府新区','5','https://www.anjuke.com/chengdu/cm/tainfuxinqu/'],['蒲江','2','www.anjuke.com/chengdu/cm/cdpujiangxian/'],['温江','7','https://www.anjuke.com/chengdu/cm/wenjiang/'],['龙泉驿','7','https://www.anjuke.com/chengdu/cm/longquanyi/'],['双流','7','https://www.anjuke.com/chengdu/cm/shuangliu/'],['都江堰','7','https://www.anjuke.com/chengdu/cm/dujiangyan/'],['郫都','9','https://www.anjuke.com/chengdu/cm/piduqu/'],['新都','8','https://www.anjuke.com/chengdu/cm/xindu/'],['青白江','3','https://www.anjuke.com/chengdu/cm/qingbaijiangqu/'],['新津','3','https://www.anjuke.com/chengdu/cm/xinjinxian/'],['金堂','4','https://www.anjuke.com/chengdu/cm/jintangxian/'],['彭州','3','https://www.anjuke.com/chengdu/cm/pengzhoushi/'],['崇州','4','https://www.anjuke.com/chengdu/cm/chongzhoushi/'],['大邑','3','https://www.anjuke.com/chengdu/cm/dayixian/'],['简阳','3','https://www.anjuke.com/chengdu/cm/jianyangsh/'],['邛崃','3','https://www.anjuke.com/chengdu/cm/qionglaishi/'],['大邑','3','https://www.anjuke.com/chengdu/cm/dayixian/']
IT 0 0 96天前
admin
47
DELETE FROM table_name
IT 0 0 101天前
LOOK官方站 联系站长
Powered by Look博客