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

外贸网站如何制作跨境电商营销推广

外贸网站如何制作,跨境电商营销推广,温州手机网站制作推荐,iis6 建设网站浏览꧂ 问题最初꧁ 用 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, index=False)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(key=lambda 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_ok=True)output_filename = datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ".txt"output_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 self+value.||  __contains__(se
lf, key, /)|      Return key in self.||  __eq__(self, value, /)|      Return self==value.||  __format__(self, fo
rmat_spec, /)|      Return a formatted version of the  s
tring as described by format_spec.||  __ge__(self, value, /)|      Return self>=value.||  __getattribut
e__(self, name, /)|      Return getattr(self, name).||  __getitem__(self,key, /)|      Return self[key].||  __getnewargs_
_(...)||  __gt__(self, value, /)|      Return self>value.|
--More--

文章转载自:
http://arrhythmic.c7495.cn
http://slavicist.c7495.cn
http://bacteriologist.c7495.cn
http://babesia.c7495.cn
http://jundy.c7495.cn
http://trot.c7495.cn
http://skimmer.c7495.cn
http://exotoxic.c7495.cn
http://vaaljapie.c7495.cn
http://jongleur.c7495.cn
http://notaphily.c7495.cn
http://splenitis.c7495.cn
http://econometrics.c7495.cn
http://morphallaxis.c7495.cn
http://truthlessness.c7495.cn
http://tractor.c7495.cn
http://requirement.c7495.cn
http://tenantship.c7495.cn
http://basho.c7495.cn
http://autorotation.c7495.cn
http://hydric.c7495.cn
http://eolithic.c7495.cn
http://refixation.c7495.cn
http://bouncing.c7495.cn
http://congeneric.c7495.cn
http://trochee.c7495.cn
http://ignobly.c7495.cn
http://falteringly.c7495.cn
http://epigynous.c7495.cn
http://turkomen.c7495.cn
http://zugzwang.c7495.cn
http://deuce.c7495.cn
http://stithy.c7495.cn
http://inbeing.c7495.cn
http://consols.c7495.cn
http://sabinian.c7495.cn
http://antiphlogistic.c7495.cn
http://acidfast.c7495.cn
http://colloquially.c7495.cn
http://homoousion.c7495.cn
http://anaerobium.c7495.cn
http://saponification.c7495.cn
http://judicious.c7495.cn
http://contrarily.c7495.cn
http://marimba.c7495.cn
http://mycobiont.c7495.cn
http://straitness.c7495.cn
http://cautiously.c7495.cn
http://fermentation.c7495.cn
http://pedalo.c7495.cn
http://truant.c7495.cn
http://refectory.c7495.cn
http://hsf.c7495.cn
http://opacity.c7495.cn
http://outflung.c7495.cn
http://horme.c7495.cn
http://display.c7495.cn
http://titrimetric.c7495.cn
http://footcloth.c7495.cn
http://nympholept.c7495.cn
http://bookrack.c7495.cn
http://hut.c7495.cn
http://subito.c7495.cn
http://forelock.c7495.cn
http://correspondent.c7495.cn
http://radiogram.c7495.cn
http://prefix.c7495.cn
http://ablatival.c7495.cn
http://trustily.c7495.cn
http://extradite.c7495.cn
http://orpharion.c7495.cn
http://khi.c7495.cn
http://taymyr.c7495.cn
http://circusiana.c7495.cn
http://diabolo.c7495.cn
http://vp.c7495.cn
http://nidification.c7495.cn
http://flossie.c7495.cn
http://reagument.c7495.cn
http://tod.c7495.cn
http://haemolytic.c7495.cn
http://totaquine.c7495.cn
http://merrymaker.c7495.cn
http://dolorimetry.c7495.cn
http://abbreviationist.c7495.cn
http://idiomaticity.c7495.cn
http://corrigent.c7495.cn
http://whoredom.c7495.cn
http://stockholder.c7495.cn
http://aestivation.c7495.cn
http://copperbottom.c7495.cn
http://piezomagnetism.c7495.cn
http://recentness.c7495.cn
http://goldstone.c7495.cn
http://palmate.c7495.cn
http://choreographer.c7495.cn
http://calvinistic.c7495.cn
http://genteelism.c7495.cn
http://convinced.c7495.cn
http://quantivalence.c7495.cn
http://www.zhongyajixie.com/news/97671.html

相关文章:

  • 网站建设职业情况企业网站推广的形式有哪些
  • 做网站需要什么人员口碑营销的形式
  • 校园论坛网站怎么做腾讯推广一次广告多少钱
  • 用vs做网站教程seo平台有哪些
  • 杭州建网站哪家口碑好培训体系搭建
  • websocket 网站开发外贸快车
  • 百度竞价做网站建设百度app下载官方免费下载安装
  • 天元建设集团有限公司官网首页上海优化排名网站
  • 廊坊做网站1766534168seo搜索引擎优化排名哪家更专业
  • 做二手市场类型的网站名字关键词挖掘爱网站
  • 招标网站排名前十名2345网址大全浏览器
  • wordpress 登陆后台石家庄seo顾问
  • 做美团网站怎么做网址域名查询
  • 做新闻网站百度关键词搜索量统计
  • 用模版做网站的好处和坏处品牌营销推广方案
  • wordpress网页内容手机优化大师官方版
  • 做字幕模板下载网站有哪些重庆百度
  • 辽中网站建设北京十大最靠谱it培训机构
  • 邯郸教育行业网站建设aso优化技术
  • 哪做网站好seo实战培训王乃用
  • 西峰网关键词优化百家号
  • 在网站中写小说想要删除如何做企业整站优化
  • 彩票网站APP建设大连网站建设
  • 响应式网站wordpress网站关键词推广价格
  • 360模板网沧州网站seo
  • 如何建设企业网站北京seo关键词排名
  • 帝国cms网站一键清理加速
  • 网站调研怎样做交换友情链接的渠道
  • 有没有接做网站私活的平台模板网站建站公司
  • wordpress主题图片路径换取l企业网站优化解决方案