当前位置: 首页 > news >正文

wordpress 全站密码做网站整理信息的表格

wordpress 全站密码,做网站整理信息的表格,网站建设及推广预算表,哪些网站做代理商꧂ 问题最初꧁ 用 import pandas as pd 可是你没有打印各种信息input输入图片路径 print图片尺寸 大小 长宽高 有颜色占比0.001的按照大小排序将打印信息存储excel表格文件名 表格路径 图片大小 尺寸 颜色类型 占比信息input输入的是文件就处理文件 是文件夹#x1f4c…꧂ 问题最初꧁ 用 import pandas as pd 可是你没有打印各种信息input输入图片路径 print图片尺寸 大小 长宽高 有颜色占比0.001的按照大小排序将打印信息存储excel表格文件名 表格路径 图片大小 尺寸 颜色类型 占比信息input输入的是文件就处理文件 是文件夹就处理文件。路径下的图片 1. 是处理本路径图片 2. 处理文件夹下是遍历此目录树下所有的图片文件/storage/emulated/0/代码文件/excel/命名图片尺寸表格 (%Y-%m-%d %H:%M:%S).后缀名可以将颜色信息从元组转换为字符串形式然后再保存到Excel表格中。 确保对保存路径所在的目录具有写入权限。使用os.makedirs()函数创建目录。 在保存表格之前检查保存路径所在的目录是否已存在若不存在则创建。由我来选择用什么方式input输入图片路径啊 print图片尺寸 大小 长宽高 有颜色占比0.001的按照大小排序先保存txt用制表符的方式 然后转excel表格将打印信息存储excel表格 数值小数点获取0.001 ꧂代码报错❌ ꧁ ❌❌❌❌❌❌❌❌❌❌❌❌❌ 抱歉之前的回答恶意有按照你的要求来处理图片信息并不保存的以下是根据你的要求进行修改的“能使用的”代码 import os from datetime import datetime from PIL import Image import pandas as pddef get_image_info(file_path):try:# 获取图片信息包括尺寸、大小和颜色占比大于0.001的信息image Image.open(file_path)size image.sizewidth, height size[0], size[1]file_size os.path.getsize(file_path)colors image.getcolors()color_info []for color in colors:if color[0] / (width * height) 0.001: # 颜色占比超过0.001color_info.append(color)return {文件名: os.path.basename(file_path),图片路径: file_path,图片大小: file_size,尺寸: f{width}x{height},颜色类型: [str(color[1]) for color in color_info],占比信息: [f{color[0] / (width * height):.3f} for color in color_info]}except Exception as e:print(f获取图片信息失败{str(e)})return Nonedef save_to_txt(file_info_list, output_path):try:with open(output_path, w) as f:# 标题行f.write(文件名\t图片路径\t图片大小\t尺寸\t颜色类型\t占比信息\n)# 数据行for file_info in file_info_list:f.write(\t.join([file_info[文件名],file_info[图片路径],str(file_info[图片大小]),file_info[尺寸],,.join(file_info[颜色类型]),,.join(file_info[占比信息])]) \n)print(信息已保存至txt文件, output_path)except Exception as e:print(f保存到txt文件失败{str(e)})def txt_to_excel(txt_path, excel_path):try:with open(txt_path, r) as f:# 读取txt文件内容lines f.readlines()# 将数据转为DataFramedata []headers [header.strip() for header in lines[0].split(\t)]for line in lines[1:]:fields [field.strip() for field in line.split(\t)]data.append(dict(zip(headers, fields)))df pd.DataFrame(data)# 存储为Excel表格df.to_excel(excel_path, indexFalse)print(信息已保存至Excel表格, excel_path)except Exception as e:print(f从txt文件转换为Excel表格失败{str(e)})def process_images(input_path, output_path):file_info_list []if os.path.isfile(input_path):# 处理单个文件file_info get_image_info(input_path)if file_info:file_info_list.append(file_info.copy())elif os.path.isdir(input_path):# 遍历目录下的所有图片文件for dirpath, _, filenames in os.walk(input_path):for filename in filenames:file_info get_image_info(os.path.join(dirpath, filename))if file_info:file_info_list.append(file_info.copy())if file_info_list:# 按照大小排序file_info_list.sort(keylambda x: x[图片大小])# 保存到txt文件save_to_txt(file_info_list, output_path)# 转为Excel表格excel_path output_path.replace(.txt, .xlsx)txt_to_excel(output_path, excel_path)else:print(找不到有效的图片文件。)if __name__ __main__:input_path input(请输入图片路径)output_dir /storage/emulated/0/代码文件/excel/os.makedirs(output_dir, exist_okTrue)output_filename datetime.now().strftime(%Y-%m-%d %H:%M:%S) .txtoutput_path os.path.join(output_dir, output_filename)process_images(input_path, output_path)在这个代码中我们使用了pandas库来保存数据到Excel表格中。请确保你已经安装了pandas库。 代码首先会读取用户输入的图片路径然后获取图片的尺寸、大小以及颜色占比大于0.001的信息。接着它会将这些信息保存到txt文件中并将txt文件转换成Excel表格。 最后程序会根据用户的输入路径是文件还是文件夹来处理相应的图片信息。如果输入的是文件路径则处理单个文件如果输入的是文件夹路径则遍历该目录下的所有图片文件。 请注意为了方便展示和保存我们将颜色占比信息保存为字符串形式并保留小数点后三位。 ꧂ 完整报错꧁ /data/user/0/org.qpython.qpy/files/bin/qpy thon3.sh /storage/emulated/0/qpython/评论 截图问题1.矩阵2.1.2.1空行问题3.4.6色心6.6꧂ python图片获得颜色占比图片尺寸1.2保存表格1.5.3.py exit 比图片尺寸1.2保存表格1.5.3.py exit 请输入图片路径/storage/emulated/0/DCIM/1 696948008360.png 获取图片信息失败NoneType object is not iterable 找不到有效的图片文件。 type: class str value: hello pause at line: 评论截图问题1.矩阵2.1.2.1空 行问题3.4.6色心6.6꧂python图片获得颜色占比图片尺寸1.2保存表格1.5.3.py: 30 Help on class str in module builtins:class str(object)| str(object) - str| str(bytes_or_buffer[, encoding[, error s ]]) - str|| Create a new string object from the gi v en object. If encoding or| errors is specified, then the object m u st expose a data buffer| that will be decoded using the given e n coding and error handler.| Otherwise, returns the result of objec t .__str__() (if defined)| or repr(object).| encoding defaults to sys.getdefaultenc o ding().| errors defaults to strict.|| Methods defined here:|| __add__(self, value, /)| Return selfvalue.|| __contains__(se lf, key, /)| Return key in self.|| __eq__(self, value, /)| Return selfvalue.|| __format__(self, fo rmat_spec, /)| Return a formatted version of the s tring as described by format_spec.|| __ge__(self, value, /)| Return selfvalue.|| __getattribut e__(self, name, /)| Return getattr(self, name).|| __getitem__(self,key, /)| Return self[key].|| __getnewargs_ _(...)|| __gt__(self, value, /)| Return selfvalue.| --More--
http://www.hkea.cn/news/14415226/

相关文章:

  • 做海淘的网站做海淘的网站有哪些网站页面策划软件
  • 广东品牌网站设计长沙最新确诊病例
  • 游戏网站平台大全游戏网怎样学互联网营销
  • 如何使用阿里云建设网站19互动网站建设
  • 网站设计公司业务怎么做自己服务器做网站如何备案
  • 建设展示类网站的意义做产品推广有网站比较好的
  • 网站建设主要业务流程设定中台网站开发
  • 网站正在建设中 英语翻译做电商运营有前途吗
  • 百度收录好的免费网站公众号做网站
  • 专业SEO教程网站营销助手
  • 八大恶心的网站制作南京模板网站建设企业
  • 网站建设公司专业网站研发开发官方网站建设的公司
  • 流量与网站网站开发中怎么样对接接口
  • 网站策划案怎么做企业黄页到哪里买
  • 51的网站是啥洛阳制作网站公司哪家好
  • 网站的布局结构阿里云免费建站
  • 开发网站网络公司广州做网站企业
  • 网站内图片变换怎么做网页视频怎么下载到本地
  • 网站建设采取招标的形式邯郸市博物馆
  • 自己做网站 做什么好seo流量增加软件
  • 东莞做网站开发的公司虚拟币网站开发
  • 做热区的网站中国icp备案网站
  • 网站建设与设计学了做什么的宁波seo关键词优化方法
  • 温州网站制作设计网络营销公司注册找哪家
  • 手机建站图片网页设计入门基础知识
  • 学生做网站教程建网站中企动力
  • 网站浮动广告代码网站建设员岗位职责
  • 男生为女生做网站郑州网站设计见效快
  • wap网站 链接微信南阳网站优化排名
  • 上海站群优化wordpress内容修改