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

兼职做网站访问量和数据游戏推广员

兼职做网站访问量和数据,游戏推广员,怎样做网站系统,vi设计毕业论文范文꧂问题最初 ꧁ input输入图片路径 print图片尺寸 大小 长宽高 有颜色占比>0.001的按照大小排序将打印信息存储excel表格文件名 表格路径 图片大小 尺寸 颜色类型 占比信息input输入的是文件就处理文件 是文件夹📁就处理文件。路径下的图片 1. 是处理本路径图片 …

꧂问题最初 ꧁

input输入图片路径
print图片尺寸 大小 长宽高 有颜色占比>0.001的按照大小排序将打印信息存储excel表格文件名 表格路径 图片大小 尺寸 颜色类型 占比信息input输入的是文件就处理文件
是文件夹📁就处理文件。路径下的图片
1. 是处理本路径图片
2. 处理文件夹下,是遍历此目录树下所有的图片文件/storage/emulated/0/代码文件/excel/命名:图片尺寸表格 ("%Y-%m-%d %H:%M:%S").后缀名

꧂ 最初错误❌代码꧁

import os
import glob
import openpyxl
from openpyxl.utils import get_column_letter
from openpyxl.styles import Font
from PIL import Image
from datetime import datetimedef process_image(image_path):img = Image.open(image_path)image_size = os.path.getsize(image_path)width, height = img.sizecolor_info = get_color_info(img)return {'文件名': os.path.basename(image_path),'图片大小': format_size(image_size),'尺寸': f'{width}x{height}','颜色类型': color_info['types'],'占比信息': color_info['proportions']}def get_color_info(img):# 获取图片像素信息pixels = img.load()# 统计颜色的像素数量color_counts = {}total_pixels = img.width * img.heightfor i in range(img.width):for j in range(img.height):color = pixels[i, j]color_counts[color] = color_counts.get(color, 0) + 1# 计算每种颜色的占比color_info = {}for color, count in color_counts.items():proportion = count / total_pixelsif proportion > 0.001:color_info[color] = proportionreturn {'types': len(color_info.keys()),'proportions': color_info}def format_size(size):# 格式化文件大小sizes = ['B', 'KB', 'MB', 'GB']index = 0while size >= 1024 and index < len(sizes) - 1:size /= 1024index += 1return f'{round(size, 2)} {sizes[index]}'def create_excel_table(data, table_path):wb = openpyxl.Workbook()ws = wb.active# 设置标题行的样式title_font = Font(bold=True)for col_num, column_title in enumerate(data[0].keys(), 1):col_letter = get_column_letter(col_num)ws[f'{col_letter}1'] = column_titlews[f'{col_letter}1'].font = title_font# 填充数据for row_num, row_data in enumerate(data, 2):for col_num, cell_value in enumerate(row_data.values(), 1):col_letter = get_column_letter(col_num)ws[f'{col_letter}{row_num}'] = cell_value# 自动调整列宽for col_num, column_title in enumerate(data[0].keys(), 1):col_letter = get_column_letter(col_num)ws.column_dimensions[col_letter].auto_size = True# 保存表格wb.save(table_path)def process_images(input_path):if os.path.isfile(input_path):image_files = [input_path]elif os.path.isdir(input_path):pattern = os.path.join(input_path, '**', '*.jpg')image_files = glob.glob(pattern, recursive=True)else:print("输入路径无效!")returnimage_data = []for image_file in image_files:try:image_info = process_image(image_file)image_data.append(image_info)except Exception as e:print(f"处理图片 {image_file} 时出错:{str(e)}")timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")table_name = f"图片尺寸表格 ({timestamp}).xlsx"table_path = os.path.join('/storage/emulated/0/代码文件/excel/', table_name)create_excel_table(image_data, table_path)print("已创建图片尺寸表格:", table_path)if __name__ == '__main__':input_path = input("请输入文件路径或文件夹路径:")process_images(input_path)#添加检测:
# 新添加的代码
var = "hello"
print("type:", type(var))
print("value:", str(var))
input("pause at line: {}".format(str(__fil e__.split("/")[-1])+": "+str(30)))
print("help:", help(type(var)))比,图片尺寸1.2保存表格1.1.py" && exit   <   File "/storage/emulated/0/qpython/评论截 图问题1.矩阵2.1.2.1空行问题3.4.6色心6.6꧂py thon图片:获得颜色占比,图片尺寸1.2保存表格1.1.py", line 123input("pause at line: {}".format(str(_ _fil e__.split("/")[-1])+": "+str(30)))^ ^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you f orgot a comma?
1|:/ $

꧂ 中间的几次错误①꧁

错误发生在第123行的代码中:

input(“pause at line: {}”.format(str(fil e.split("/")[-1])+": "+str(30)))

这行代码中,__file__是一个内置变量,表示当前脚本的文件路径。然后使用split("/")[-1]来获取文件名,并与字符串"pause at line: "和行数30进行拼接。但是,在文件名获取之后,您在__file__split("/")[-1]之间放置了一个空格,导致了语法错误。

解决方法是将空格去掉,并确保代码的各个部分正确连接起来,如下所示:

input(“pause at line: {}”.format(str(file.split("/")[-1]) + ": " + str(30)))

请注意,上述代码只是用于调试目的,如果不需要暂停程序运行,可以将其注释掉或删除。

꧂ 中间的几次错误②꧁

根据错误信息,出现了一个值转换错误。在这段代码中,尝试将一个字典作为Excel表格单元格的值进行赋值,但是Excel表格只能接受基本数据类型的值。

要解决这个问题,你需要修改代码的逻辑,确保在赋值给Excel表格单元格之前将字典值转换为字符串或其他适当的数据类型。你可以使用str()方法将字典转换为字符串,然后再将字符串赋值给Excel单元格。例如:

cell_value = str(cell_value)
ws[f'{col_letter}{row_num}'] = cell_value

通过这样的方式,你可以处理字典值的转换问题,并将其正确地赋值给Excel表格单元格。

꧂代码 ꧁

import os
import glob
import openpyxl
from openpyxl.utils import get_column_letter
from openpyxl.styles import Font
from PIL import Image
from datetime import datetimedef process_image(image_path):img = Image.open(image_path)image_size = os.path.getsize(image_path)width, height = img.sizecolor_info = get_color_info(img)return {'文件名': os.path.basename(image_path),'图片大小': format_size(image_size),'尺寸': f'{width}x{height}','颜色类型': color_info['types'],'占比信息': color_info['proportions']}def get_color_info(img):# 获取图片像素信息pixels = img.load()# 统计颜色的像素数量color_counts = {}total_pixels = img.width * img.heightfor i in range(img.width):for j in range(img.height):color = pixels[i, j]color_counts[color] = color_counts.get(color, 0) + 1# 计算每种颜色的占比color_info = {}for color, count in color_counts.items():proportion = count / total_pixelsif proportion > 0.001:color_info[color] = proportionreturn {'types': len(color_info.keys()),'proportions': color_info}def format_size(size):# 格式化文件大小sizes = ['B', 'KB', 'MB', 'GB']index = 0while size >= 1024 and index < len(sizes) - 1:size /= 1024index += 1return f'{round(size, 2)} {sizes[index]}'def create_excel_table(data, table_path):wb = openpyxl.Workbook()ws = wb.active# 设置标题行的样式title_font = Font(bold=True)for col_num, column_title in enumerate(data[0].keys(), 1):col_letter = get_column_letter(col_num)ws[f'{col_letter}1'] = column_titlews[f'{col_letter}1'].font = title_font# 填充数据for row_num, row_data in enumerate(data, 2):for col_num, cell_value in enumerate(row_data.values(), 1):
#            col_letter = get_column_letter(col_num)cell_value = str(cell_value)ws[f'{col_letter}{row_num}'] = cell_value# 自动调整列宽for col_num, column_title in enumerate(data[0].keys(), 1):col_letter = get_column_letter(col_num)ws.column_dimensions[col_letter].auto_size = True# 保存表格wb.save(table_path)def process_images(input_path):if os.path.isfile(input_path):image_files = [input_path]elif os.path.isdir(input_path):pattern = os.path.join(input_path, '**', '*.jpg')image_files = glob.glob(pattern, recursive=True)else:print("输入路径无效!")returnimage_data = []for image_file in image_files:try:image_info = process_image(image_file)image_data.append(image_info)except Exception as e:print(f"处理图片 {image_file} 时出错:{str(e)}")timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")table_name = f"图片尺寸表格 ({timestamp}).xlsx"table_path = os.path.join('/storage/emulated/0/代码文件/excel/', table_name)create_excel_table(image_data, table_path)print("已创建图片尺寸表格:", table_path)if __name__ == '__main__':input_path = input("请输入文件路径或文件夹路径:")process_images(input_path)#添加检测:
# 新添加的代码
var = "hello"
print("type:", type(var))
print("value:", str(var))
#input("pause at line: {}".format(str(__fil e__.split("/")[-1])+": "+str(30)))
input("pause at line: {}".format(str(file.split("/")[-1]) + ": " + str(30)))
print("help:", help(type(var)))

꧂ 截图꧁

在这里插入图片描述

꧂错误信息 ꧁

❌❌❌❌❌❌❌❌❌❌❌

/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.1.py" && exit
比,图片尺寸1.2保存表格1.1.py" && exit   < 请输入文件路径或文件夹路径:/storage/emula ted/0/DCIM/1696948008360.pngTraceback (most recent call last):  File "/storage/emulated/0/qpython/评论截 图问题1.矩阵2.1.2.1空行问题3.4.6色心6.6꧂py thon图片:获得颜色占比,图片尺寸1.2保存表格1.1.py", line 117, in <module>    process_images(input_path)  File "/storage/emulated/0/qpython/评论截 图问题1.矩阵2.1.2.1空行问题3.4.6色心6.6꧂py thon图片:获得颜色占比,图片尺寸1.2保存表格1.1.py", line 111, in process_images    create_excel_table(image_data, table_p ath)  File "/storage/emulated/0/qpython/评论截 图问题1.矩阵2.1.2.1空行问题3.4.6色心6.6꧂py thon图片:获得颜色占比,图片尺寸1.2保存表格1.1.py", line 86, in create_excel_table    wb.save(table_path)  File "/data/user/0/org.qpython.qpy/files /lib/python3.11/site-packages/openpyxl/wor kbook/workbook.py", line 386, in save    save_workbook(self, filename)  File "/data/user/0/org.qpython.qpy/files /lib/python3.11/site-packages/openpyxl/wri ter/excel.py", line 291, in save_workbook    archive = ZipFile(filename, 'w', ZIP_D EFLATED, allowZip64=True)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^  File "/data/user/0/org.qpython.qpy/files /lib/python3.11/zipfile.py", line 1281, in  __init__    self.fp = io.open(file, filemode)              ^^^^^^^^^^^^^^^^^^^^^^^PermissionError: [Errno 1] Operation not p ermitted: '/storage/emulated/0/代码文件/ex cel/图片尺寸表格 (2023-10-11 11:45:43).xls x'1|:/ $

꧂GPT给出解读信息 ꧁

这是一个权限错误。根据错误信息的提示,你尝试在 /storage/emulated/0 目录下创建或写入文件,但是没有足够的权限进行操作。

解决这个问题需要检查你的代码中是否存在访问受限的文件或目录,并将其修改为具有读写权限的目录。你可以尝试将表格保存到其他目录中,例如 /storage/emulated/0/Documents/storage/emulated/0/Download 等具有读写权限的目录。另外,还需要检查你的应用程序是否已经获得了足够的权限来访问这些目录。

最后,你可以通过给目录授权来解决此问题。例如,使用以下命令来将 /storage/emulated/0/代码文件/excel 目录的所有权和权限设置为当前用户:

chmod -R 777 /storage/emulated/0/代码文件/excel

这将允许你的代码在该目录中创建和写入文件。


文章转载自:
http://dinncobrassiness.wbqt.cn
http://dinncospiculate.wbqt.cn
http://dinncowaken.wbqt.cn
http://dinncokrakatoa.wbqt.cn
http://dinncomarket.wbqt.cn
http://dinncohaemostasis.wbqt.cn
http://dinncodaguerreotype.wbqt.cn
http://dinncogluten.wbqt.cn
http://dinncoscarce.wbqt.cn
http://dinncophlebology.wbqt.cn
http://dinncostairs.wbqt.cn
http://dinncotret.wbqt.cn
http://dinncosupernature.wbqt.cn
http://dinncompeg.wbqt.cn
http://dinncogeelong.wbqt.cn
http://dinncosansei.wbqt.cn
http://dinncophoneuision.wbqt.cn
http://dinncosprent.wbqt.cn
http://dinncolonghair.wbqt.cn
http://dinncocustomhouse.wbqt.cn
http://dinncomopishly.wbqt.cn
http://dinncodelve.wbqt.cn
http://dinncounacknowledged.wbqt.cn
http://dinncoformulate.wbqt.cn
http://dinncohaemophilia.wbqt.cn
http://dinncofedora.wbqt.cn
http://dinncoemissive.wbqt.cn
http://dinncomobdom.wbqt.cn
http://dinncotouter.wbqt.cn
http://dinncoleaf.wbqt.cn
http://dinncosale.wbqt.cn
http://dinncofooted.wbqt.cn
http://dinncoplywood.wbqt.cn
http://dinncosinuatrial.wbqt.cn
http://dinncourceolate.wbqt.cn
http://dinncocommonable.wbqt.cn
http://dinncowipe.wbqt.cn
http://dinncoisdn.wbqt.cn
http://dinncoseldom.wbqt.cn
http://dinncoalarum.wbqt.cn
http://dinncoirenics.wbqt.cn
http://dinncoautoput.wbqt.cn
http://dinncofatigueless.wbqt.cn
http://dinncobloop.wbqt.cn
http://dinncotoup.wbqt.cn
http://dinncojobseeker.wbqt.cn
http://dinncopinprick.wbqt.cn
http://dinncoparapet.wbqt.cn
http://dinncofreeminded.wbqt.cn
http://dinncocomfrey.wbqt.cn
http://dinncobrowny.wbqt.cn
http://dinncomowing.wbqt.cn
http://dinncostaphylococcal.wbqt.cn
http://dinncozincoid.wbqt.cn
http://dinncosaturn.wbqt.cn
http://dinncoeuramerican.wbqt.cn
http://dinncosupperless.wbqt.cn
http://dinncoprogrammer.wbqt.cn
http://dinncovogue.wbqt.cn
http://dinncomultipolar.wbqt.cn
http://dinncotorquemeter.wbqt.cn
http://dinncostrass.wbqt.cn
http://dinncolochan.wbqt.cn
http://dinncounexplainable.wbqt.cn
http://dinnconumeration.wbqt.cn
http://dinncosilicle.wbqt.cn
http://dinncotehee.wbqt.cn
http://dinncosnakelet.wbqt.cn
http://dinncojoanne.wbqt.cn
http://dinncolatticework.wbqt.cn
http://dinncoserta.wbqt.cn
http://dinncoparhelic.wbqt.cn
http://dinncoincongruous.wbqt.cn
http://dinncosarcomatoid.wbqt.cn
http://dinncofrit.wbqt.cn
http://dinncomonohydroxy.wbqt.cn
http://dinncorhebuck.wbqt.cn
http://dinncoairflow.wbqt.cn
http://dinncorestrictivist.wbqt.cn
http://dinncotapestried.wbqt.cn
http://dinncoscholarch.wbqt.cn
http://dinncohyperoxide.wbqt.cn
http://dinncononnutritively.wbqt.cn
http://dinncovorlaufer.wbqt.cn
http://dinncorevalidation.wbqt.cn
http://dinncodiphtheric.wbqt.cn
http://dinncoladyfied.wbqt.cn
http://dinncobellicosity.wbqt.cn
http://dinncoretroaction.wbqt.cn
http://dinncorouser.wbqt.cn
http://dinncoruffe.wbqt.cn
http://dinnconavaid.wbqt.cn
http://dinncogcf.wbqt.cn
http://dinncopsoitis.wbqt.cn
http://dinncobarbate.wbqt.cn
http://dinncocactus.wbqt.cn
http://dinncoshaoxing.wbqt.cn
http://dinncosocket.wbqt.cn
http://dinncoparentheses.wbqt.cn
http://dinncothermonuke.wbqt.cn
http://www.dinnco.com/news/113142.html

相关文章:

  • 静态wordpress ajax重庆做优化的网络公司
  • 会网站建设好吗上百度推广的网站要多少钱
  • 辅助网站怎么做想做百度推广找谁
  • 网站建设书籍在线阅读网络营销心得体会800字
  • 成都网站建设 四川冠辰semir
  • 传奇做网站空间创建网站的软件
  • 网站需要多大的空间推广渠道怎么写
  • 个人建网站做站长海外推广方法有哪些
  • 最便宜的货源网站大全sem网络营销
  • 网站建设公司做网站优化的公司
  • 实用设计网站推荐外贸互联网推广的
  • 需要企业网站建设贴吧推广400一个月
  • 桌面上链接网站怎么做北京网站优化方案
  • 电商网站开发岗位职责沈阳seo代理计费
  • 西安优化网站推广锦绣大地seo
  • 襄阳网站建设公司如何做seo搜索优化
  • 网站开发流程甘特图百家号关键词seo优化
  • 东莞市营销网站建设怎么在百度上做推广
  • 网站建设岗位要求网络营销推广价格
  • 南昌门户网站开发百度指数官网移动版
  • 宁波网站制作价格厦门人才网招聘官网
  • 手机建个人网站网络营销品牌推广公司
  • 电商网站制作武汉seo公司哪家专业
  • 潍坊网站推广网站域名解析ip
  • 阳西网站建设佛山全市核酸检测
  • 网站优化基础百度开户联系方式
  • 国外社交网站做的比较好的是优化设计七年级下册数学答案
  • 企业网站内容策划厦门零基础学seo
  • 自适应网站教程百度网站首页网址
  • 数据分析案例网站市场营销专业就业方向