s网站优化,网站备案 时间更新,切片工具做网站怎么做,建站公司 网站背景需求#xff1a; 
有一位客户买3宫格所有可能#xff08;WORD表格版#xff09; 【教学类-43-25】20241203 数独3宫格的所有可能-使用模版替换-用时少报错少#xff08;12套样式#xff0c;空1格-空8格#xff0c;每套510张#xff0c;共6120小图#xff09;_数独三… 
背景需求 
有一位客户买3宫格所有可能WORD表格版 【教学类-43-25】20241203 数独3宫格的所有可能-使用模版替换-用时少报错少12套样式空1格-空8格每套510张共6120小图_数独三宫格题目-CSDN博客文章浏览阅读2.3k次点赞74次收藏9次。【教学类-43-25】20241203 数独3宫格的所有可能-使用模版替换-用时少报错少12套样式空1格-空8格每套510张共6120小图_数独三宫格题目https://blog.csdn.net/reasonsummer/article/details/144225973?spm1011.2415.3001.5331 
这让我想起3宫格生成的漫长时间510图*12套生成了8个小时还有4宫格生成的恐惧——用word的12图插入数字的方法页数太多合并WORD总是卡死无法合并成一个文件 修改思路 
所以这次参考“像素图图片版”也做一份所有数独样式的图片版 
【教学类-13-19】20250228《数字色块像素图》图片版1-4位数-CSDN博客文章浏览阅读1.5k次点赞48次收藏13次。【教学类-13-19】20250228《数字色块像素图》图片版1-4位数https://blog.csdn.net/reasonsummer/article/details/145931618?spm1011.2415.3001.5331 
测试过程不提直接上代码 目的数独3宫格,所有可能样式做成图片
作者阿夏
时间20250311import math,os,time
from itertools import permutations
import random
from win32com.client import constants, gencache
from win32com.client.gencache import EnsureDispatch
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT, WD_BREAK
from docx.oxml.ns import qn
from docxtpl import DocxTemplate
import pandas as pd
from docx2pdf import convert
from datetime import datetimefrom PIL import Image, ImageDraw, ImageFont
import os
import copy# 开始时间
start_time  datetime.now()# 制作单元格# 几宫格
hs3
# int(input(3宫格数独3\n))
# 内容太多了容易报错如果报错就重新设置起始宫格数字1-8
start1
# 第几套第一套# 新建一个”装N份word和PDF“的临时文件夹
# 创建输出目录
path  rC:\Users\jg2yXRZ\OneDrive\桌面\20250311 3宫格所有可能图片版\01三宫格图片版
output_dir  path  r\00全部
os.makedirs(output_dir, exist_okTrue)print(------第2步制作3宫格的12套题的内容-------)# 制作3宫格的12套题目没有空格只有基础模板
lst[]
for b in range(1,hs1):lst.append(b)
print(lst)permutations_list  list(permutations(lst))
numbers  [list(permutation) for permutation in permutations_list]
print(numbers)
# [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]
# 6种组合# 互相组合成3组
import itertools# 计算排列数量并生成所有可能的排列
combinations2  list(itertools.permutations(numbers, hs))
# 包含相似的# 输出排列数量
print(len(combinations2))
# 120# # 把所有数字都提取成元素
ll[]
for o1 in combinations2:for o2 in o1:for o3 in o2:ll.append(o3)print(ll)
print(len(ll))
# 1080vhs*hs
# 9个数字抽取一组
f[]
for i in range(int(len(ll)/v)):f.append(ll[i*v:i*vv])
# print(f)
# print(len(f))
#120条# # # 遍历表格把0、5、10相同的内容删除,横向的数字1234都正确了现在只要排除竖向不对的P[]
z[]
for k in f:  if int(k[0])!int(k[3])!int(k[6]) and int(k[0])int(k[3])int(k[6])6 and\int(k[1])!int(k[4])!int(k[7]) and int(k[1])int(k[4])int(k[7])6 and\int(k[2])!int(k[5])!int(k[8]) and int(k[2])int(k[5])int(k[8])6 and\int(k[0])!int(k[1])!int(k[2]) and int(k[0])int(k[1])int(k[2])6 and\int(k[3])!int(k[4])!int(k[5]) and int(k[3])int(k[4])int(k[5])6 and\int(k[6])!int(k[7])!int(k[8]) and int(k[6])int(k[7])int(k[8])6 :z.append(k)print(z)
print(len(z))# 12种基础样式
basis[]
for hh in z:print(hh)basis.append(hh)
print(basis)
print(len(basis))    # 12种基础样式
# [1, 2, 3, 2, 3, 1, 3, 1, 2]
# [1, 2, 3, 3, 1, 2, 2, 3, 1]
# [1, 3, 2, 2, 1, 3, 3, 2, 1]
# [1, 3, 2, 3, 2, 1, 2, 1, 3]
# [2, 1, 3, 1, 3, 2, 3, 2, 1]
# [2, 1, 3, 3, 2, 1, 1, 3, 2]
# [2, 3, 1, 1, 2, 3, 3, 1, 2]
# [2, 3, 1, 3, 1, 2, 1, 2, 3]
# [3, 1, 2, 1, 2, 3, 2, 3, 1]
# [3, 1, 2, 2, 3, 1, 1, 2, 3]
# [3, 2, 1, 1, 3, 2, 2, 1, 3]
# [3, 2, 1, 2, 1, 3, 1, 3, 2]
# # # 12道题目jcpathfr\{hs}宫格 基础{int(len(basis))}种
os.makedirs(jc,exist_okTrue)# 制作12张原始基础样式
for n2 in range(len(basis)):# for ns in range(len(styles2[nt][nr])):t2basis[n2]print(t2)# 设置画布参数rows  3cols  3cell_size  100border_width  10canvas_width  cols * cell_size  border_width * 2canvas_height  rows * cell_size  border_width * 2# 加载字体font_path  rC:\Windows\Fonts\arial.ttf  # 替换成你的字体文件路径font_size  60font  ImageFont.truetype(font_path, font_size)# 创建图像canvas_color  (255, 255, 255)  # 白色image  Image.new(RGB, (canvas_width, canvas_height), canvas_color)draw  ImageDraw.Draw(image)# 绘制边框draw.rectangle([(0, 0), (canvas_width, canvas_height)], outline(0, 0, 0), widthborder_width)# 计算内部区域的起始点和结束点inner_start_x  border_widthinner_end_x  canvas_width - border_widthinner_start_y  border_widthinner_end_y  canvas_height - border_width# 绘制表格去掉边框线10磅for row in range(rows  1):start_y  inner_start_y  row * cell_sizedraw.line((inner_start_x, start_y, inner_end_x, start_y), fill(0, 0, 0))  # 水平线for col in range(cols  1):start_x  inner_start_x  col * cell_sizedraw.line((start_x, inner_start_y, start_x, inner_end_y), fill(0, 0, 0))  # 垂直线    # 在每个单元格的中心点写入数字for row in range(rows):for col in range(cols):index  row * cols  colnumber  t2[index]text  str(number)text_width, text_height  draw.textsize(text, fontfont)center_x  inner_start_x  col * cell_size  (cell_size - text_width) // 2center_y  inner_start_y  row * cell_size  (cell_size - text_height) // 2 - 10# 绘制数字draw.text((center_x, center_y), text, fontfont, fill(0, 0, 0))# 绘制下划线underline_y  center_y  text_height // 1  10  # 调整下划线位置使其位于数字下方draw.line((center_x - text_width //10, underline_y, center_x  text_width *1, underline_y), fill(0, 0, 0), width2)# 保存图像output_path1  os.path.join(jc, f{hs}宫格 基础样式{n21:02}.png)image.save(output_path1)print(fImage saved to {output_path1})print(---------第3步原始列表生成样式1了解数量和空格位置----------)
# 读取每一款假设任意缺1空、任意缺2空任意缺三空
# 原始列表
import itertools
m1names[]
styles1[]
styles2[]for a1 in  range(len(basis)):   abasis[a1]print(a)# [1, 2, 3, 2, 3, 1, 3, 1, 2]# 12张一页的样式n0xx0for x in range(start,hs*hs):# 如果报错就从相应的宫格数字继续生成l1[]# 使用 combinations 生成所有不重复的组合combinations  list(itertools.combinations(range(len(a)), x))# 1有9次2有36次3有84次4有84次3有84次3有84次3有84次3有84次3有84次3有84次# 打印组合及其索引并将索引位置的内容变成 for comb in combinations:# 创建副本以避免修改原始列表modified_list  a[:]# 将组合中的索引位置内容替换为 for index in comb:modified_list[index]  # print(f{modified_list})# print(fCombination: {[modified_list[i] for i in comb]}, Indices: {comb})l1.append(modified_list)# 输出组合的数量# print(l)   tf{hs}宫格 样式{a11:02} {x}空有{len(l1)}种print(f{hs}宫格 样式{a11:02} {x}空有{len(l1)}种)names.append(t)# 1空有9种# 2空有36种# 3空有84种# 4空有126种# 5空有126种# 6空有84种# 7空有36种# 8空有9种# 9空有1种nlen(combinations)# # 3宫格1套511种# print(n)    # 510# # 3宫格1套,12种图案每种510,共6132种# print(n*len(basis))#     print(n*576)# 将嵌套列表转换为扁平列表flat_list  [item for sublist in l1 for item in sublist]print(flat_list)print(len(flat_list))# 81# 将 flat_list 拆分成每组包含9个元素的嵌套列表grouped_list [flat_list[i:i  hs*hs] for i in range(0, len(flat_list),  hs*hs)]print(grouped_list)print(len(grouped_list))print(数字9个,grouped_list)styles1.append(grouped_list)# styles2.append(styles1)print(names)
print(len(names))
# 8种名称1-9
# 96种
# print(styles1)
# print(len(styles1)) # print(styles2)
# print(len(styles2))  
# 96种
# # 8种列表每种数量不等呈现正态分布    for nt in range(len(styles1)):# 按照样式1、2、3分组# wjoutput_dirfr\{hs}宫格 样式{nt:02}# os.makedirs(wj,exist_okTrue)for nr in range(len(styles1[nt])):# for ns in range(len(styles2[nt][nr])):tstyles1[nt][nr]print(t)# 设置画布参数rows  3cols  3cell_size  100border_width  10canvas_width  cols * cell_size  border_width * 2canvas_height  rows * cell_size  border_width * 2# 加载字体font_path  rC:\Windows\Fonts\arial.ttf  # 替换成你的字体文件路径font_size  60font  ImageFont.truetype(font_path, font_size)# 创建图像canvas_color  (255, 255, 255)  # 白色image  Image.new(RGB, (canvas_width, canvas_height), canvas_color)draw  ImageDraw.Draw(image)# 绘制边框draw.rectangle([(0, 0), (canvas_width, canvas_height)], outline(0, 0, 0), widthborder_width)# 计算内部区域的起始点和结束点inner_start_x  border_widthinner_end_x  canvas_width - border_widthinner_start_y  border_widthinner_end_y  canvas_height - border_width# 绘制表格去掉边框线10磅for row in range(rows  1):start_y  inner_start_y  row * cell_sizedraw.line((inner_start_x, start_y, inner_end_x, start_y), fill(0, 0, 0))  # 水平线for col in range(cols  1):start_x  inner_start_x  col * cell_sizedraw.line((start_x, inner_start_y, start_x, inner_end_y), fill(0, 0, 0))  # 垂直线    # 在每个单元格的中心点写入数字for row in range(rows):for col in range(cols):index  row * cols  colnumber  t[index]text  str(number)text_width, text_height  draw.textsize(text, fontfont)center_x  inner_start_x  col * cell_size  (cell_size - text_width) // 2center_y  inner_start_y  row * cell_size  (cell_size - text_height) // 2 - 10# 绘制数字draw.text((center_x, center_y), text, fontfont, fill(0, 0, 0))# 绘制下划线underline_y  center_y  text_height // 1  10  # 调整下划线位置使其位于数字下方draw.line((center_x - text_width //10, underline_y, center_x  text_width *1, underline_y), fill(0, 0, 0), width2)# 保存图像output_path  os.path.join(output_dir, f{names[nt]} {nr1:03}.png)image.save(output_path)print(fImage saved to {output_path})# 每510张打包再一起,样式1 510张、样式2 510张、样式3 510张  
import os
import shutil# 设置源文件夹路径
source_folder  output_dir
print(source_folder)# C:\Users\jg2yXRZ\OneDrive\桌面\20250311 3宫格所有可能图片版\01三宫格图片版\00全部
basis  [1] * 12
n  510
hs  3  # Assuming hs is defined somewhere in your code
# path  your_path  # Replace with your actual path# 创建目标文件夹
for i in range(1, int(len(basis)  1)):  # 假设总共有30个文件分成3组folder_name  os.path.join(path, f{hs}宫格 样式{i:02})os.makedirs(folder_name, exist_okTrue)# 获取所有图片文件名
image_files  [f for f in os.listdir(source_folder) if f.endswith((.png, .jpg, .jpeg))]# 分组并复制文件 n510
group_size  n
for i, file in enumerate(image_files):group_index  i // group_size  1  # 计算当前文件属于第几组source_path  os.path.join(source_folder, file)destination_path  os.path.join(path, f{hs}宫格 样式{group_index:02}, file)shutil.copy(source_path, destination_path)print(fCopied {file} to {destination_path})# 记录程序结束时间
end_time  datetime.now()# 计算程序运行时间
elapsed_time  end_time - start_timeprint(f数独{hs}宫格程序开始时间:{start_time})
print(f数独{hs}宫格程序结束时间:{end_time})# 打印程序运行时间
print(程序运行时间, elapsed_time) 
第1步生成3宫格12套基本样式 
第2步生成3宫格每套基本样式中的所有可能空1格有9种空2个有36种……每种有510种不同图案乘以12套 第3步以510张为分割图片复制到“样式1”“样式2”文件夹中。 好了用这个方法优势 
1、生成图片是320*320像素 2、大小都是9KB 3、6120张图片生成和转移时间大约2分钟。 以图片方式直接获取数独内容可以反复引用制作出一页12张一页6张一页2张一页1张的模版。 
做成PDF可能生成WORD的时间比较长 后续 
把这个代码修改一下做 一套4宫格所有可能图片版 目的数独4宫格,所有可能样式做成图片调整下划线位置
作者阿夏
时间20250311import math,os,time
from itertools import permutations
import random
from win32com.client import constants, gencache
from win32com.client.gencache import EnsureDispatch
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT, WD_BREAK
from docx.oxml.ns import qn
from docxtpl import DocxTemplate
import pandas as pd
from docx2pdf import convert
from datetime import datetimefrom PIL import Image, ImageDraw, ImageFont
import os
import copy# 开始时间
start_time  datetime.now()# 制作单元格# 几宫格
hs4
# int(input(4宫格数独3\n))
# 内容太多了容易报错如果报错就重新设置起始宫格数字1-8
start1
# 第几套第一套# 新建一个”装N份word和PDF“的临时文件夹
# 创建输出目录
path  rC:\Users\jg2yXRZ\OneDrive\桌面\20250311 4宫格所有可能图片版\01四宫格图片版
os.makedirs(path, exist_okTrue)
output_dir  path  r\00全部
os.makedirs(output_dir, exist_okTrue)print(------第2步制作4宫格的12套题的内容-------)# 制作4宫格的12套题目没有空格只有基础模板
lst[]
for b in range(1,hs1):lst.append(b)
print(lst)permutations_list  list(permutations(lst))
numbers  [list(permutation) for permutation in permutations_list]
# print(numbers)
# [[1, 2, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4], [1, 3, 4, 2], [1, 4, 2, 3], [1, 4, 3, 2], [2, 1, 3, 4], [2, 1, 4, 3], [2, 3, 1, 4], [2, 3, 4, 1], [2, 4, 1, 3], [2, 4, 3, 1], [3, 1, 2, 4], [3, 1, 4, 2], [3, 2, 1, 4], [3, 2, 4, 1], [3, 4, 1, 2], [3, 4, 2, 1], [4, 1, 2, 3], [4, 1, 3, 2], [4, 2, 1, 3], [4, 2, 3, 1], [4, 3, 1, 2], [4, 3, 2, 1]]PS D:\test
# 6种组合# 互相组合成3组
import itertools# 计算排列数量并生成所有可能的排列
combinations2  list(itertools.permutations(numbers, hs))
# 包含相似的# 输出排列数量
print(len(combinations2))
# 120# # 把所有数字都提取成元素
ll[]
for o1 in combinations2:for o2 in o1:for o3 in o2:ll.append(o3)print(ll)
print(len(ll))
# 1080vhs*hs
# 9个数字抽取一组
f[]
for i in range(int(len(ll)/v)):f.append(ll[i*v:i*vv])
# print(f)
# print(len(f))
#120条# # # 遍历表格把0、5、10相同的内容删除,横向的数字1234都正确了现在只要排除竖向不对的P[]
z[]
for k in f:  if int(k[0])!int(k[4])and int(k[0])!int(k[8])and int(k[0])!int(k[12]) and int(k[4])!int(k[8]) and int(k[4])!int(k[12])and int(k[8])!int(k[12]) and int(k[0])int(k[4])int(k[8])int(k[12])10 and \int(k[1])!int(k[5])and int(k[1])!int(k[9])and int(k[1])!int(k[13]) and int(k[5])!int(k[9]) and int(k[5])!int(k[13])and int(k[9])!int(k[13])  and int(k[1])int(k[5])int(k[9])int(k[13])10 and \int(k[2])!int(k[6])and int(k[2])!int(k[10])and int(k[2])!int(k[14]) and int(k[6])!int(k[10]) and int(k[6])!int(k[14])and int(k[10])!int(k[14]) and int(k[2])int(k[6])int(k[10])int(k[14])10 and\int(k[3])!int(k[7])and int(k[3])!int(k[11])and int(k[3])!int(k[15]) and int(k[7])!int(k[11]) and int(k[7])!int(k[15])and int(k[11])!int(k[15])  and int(k[3])int(k[7])int(k[11])int(k[15])10:z.append(k)# print(z)
# print(len(z))# 12种基础样式
basis[]
for hh in z:print(hh)basis.append(hh)
# print(basis)
# print(len(basis))   # 576种基础样式# [1, 2, 3, 4, 2, 1, 4, 3, 3, 4, 1, 2, 4, 3, 2, 1]
# [1, 2, 3, 4, 2, 1, 4, 3, 3, 4, 2, 1, 4, 3, 1, 2]
# [1, 2, 3, 4, 2, 1, 4, 3, 4, 3, 1, 2, 3, 4, 2, 1]
# [1, 2, 3, 4, 2, 1, 4, 3, 4, 3, 2, 1, 3, 4, 1, 2]
# [1, 2, 3, 4, 2, 3, 4, 1, 3, 4, 1, 2, 4, 1, 2, 3]
# [1, 2, 3, 4, 2, 3, 4, 1, 4, 1, 2, 3, 3, 4, 1, 2]
# [1, 2, 3, 4, 2, 4, 1, 3, 3, 1, 4, 2, 4, 3, 2, 1]
# [1, 2, 3, 4, 2, 4, 1, 3, 4, 3, 2, 1, 3, 1, 4, 2]
# [1, 2, 3, 4, 3, 1, 4, 2, 2, 4, 1, 3, 4, 3, 2, 1]
# [1, 2, 3, 4, 3, 1, 4, 2, 4, 3, 2, 1, 2, 4, 1, 3]
# [1, 2, 3, 4, 3, 4, 1, 2, 2, 1, 4, 3, 4, 3, 2, 1]
# [1, 2, 3, 4, 3, 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, 1, 4, 3, 3, 2, 1, 4, 1, 4, 3, 2]
# [4, 3, 2, 1, 2, 1, 4, 3, 3, 4, 1, 2, 1, 2, 3, 4]
# [4, 3, 2, 1, 2, 4, 1, 3, 1, 2, 3, 4, 3, 1, 4, 2]
# [4, 3, 2, 1, 2, 4, 1, 3, 3, 1, 4, 2, 1, 2, 3, 4]
# [4, 3, 2, 1, 3, 1, 4, 2, 1, 2, 3, 4, 2, 4, 1, 3]
# [4, 3, 2, 1, 3, 1, 4, 2, 2, 4, 1, 3, 1, 2, 3, 4]
# [4, 3, 2, 1, 3, 2, 1, 4, 1, 4, 3, 2, 2, 1, 4, 3]
# [4, 3, 2, 1, 3, 2, 1, 4, 2, 1, 4, 3, 1, 4, 3, 2]
# [4, 3, 2, 1, 3, 4, 1, 2, 1, 2, 3, 4, 2, 1, 4, 3]
# [4, 3, 2, 1, 3, 4, 1, 2, 1, 2, 4, 3, 2, 1, 3, 4]
# [4, 3, 2, 1, 3, 4, 1, 2, 2, 1, 3, 4, 1, 2, 4, 3]
# [4, 3, 2, 1, 3, 4, 1, 2, 2, 1, 4, 3, 1, 2, 3, 4]# 576道题目jcpathfr\{hs}宫格 基础{int(len(basis))}种
os.makedirs(jc,exist_okTrue)# 制作12张原始基础样式
for n2 in range(len(basis)):# for ns in range(len(styles2[nt][nr])):t2basis[n2]print(t2)# 设置画布参数rows  4cols  4cell_size  100border_width  10canvas_width  cols * cell_size  border_width * 2canvas_height  rows * cell_size  border_width * 2# 加载字体font_path  rC:\Windows\Fonts\arial.ttf  # 替换成你的字体文件路径font_size  60font  ImageFont.truetype(font_path, font_size)# 创建图像canvas_color  (255, 255, 255)  # 白色image  Image.new(RGB, (canvas_width, canvas_height), canvas_color)draw  ImageDraw.Draw(image)# 绘制边框draw.rectangle([(0, 0), (canvas_width, canvas_height)], outline(0, 0, 0), widthborder_width)# 计算内部区域的起始点和结束点inner_start_x  border_widthinner_end_x  canvas_width - border_widthinner_start_y  border_widthinner_end_y  canvas_height - border_width# 绘制表格去掉边框线10磅for row in range(rows  1):start_y  inner_start_y  row * cell_sizedraw.line((inner_start_x, start_y, inner_end_x, start_y), fill(0, 0, 0))  # 水平线for col in range(cols  1):start_x  inner_start_x  col * cell_sizedraw.line((start_x, inner_start_y, start_x, inner_end_y), fill(0, 0, 0))  # 垂直线    # 在每个单元格的中心点写入数字for row in range(rows):for col in range(cols):index  row * cols  colnumber  t2[index]text  str(number)text_width, text_height  draw.textsize(text, fontfont)center_x  inner_start_x  col * cell_size  (cell_size - text_width) // 2center_y  inner_start_y  row * cell_size  (cell_size - text_height) // 2 - 10# 绘制数字draw.text((center_x, center_y), text, fontfont, fill(0, 0, 0))# 绘制下划线underline_y  center_y  text_height // 1  10  # 调整下划线位置使其位于数字下方draw.line((center_x - text_width //10, underline_y, center_x  text_width *1, underline_y), fill(0, 0, 0), width2)# 保存图像output_path1  os.path.join(jc, f{hs}宫格 基础样式{n21:03}.png)image.save(output_path1)print(fImage saved to {output_path1})print(---------第3步原始列表生成样式1了解数量和空格位置----------)
# 读取每一款假设任意缺1空、任意缺2空任意缺三空
# 原始列表
import itertools
m1names[]
styles1[]
styles2[]for a1 in  range(len(basis)):   abasis[a1]print(a)# [1, 2, 3, 2, 3, 1, 3, 1, 2]# 12张一页的样式n0xx0for x in range(start,hs*hs):# 如果报错就从相应的宫格数字继续生成l1[]# 使用 combinations 生成所有不重复的组合combinations  list(itertools.combinations(range(len(a)), x))# 1有9次2有36次3有84次4有84次3有84次3有84次3有84次3有84次3有84次3有84次# 打印组合及其索引并将索引位置的内容变成 for comb in combinations:# 创建副本以避免修改原始列表modified_list  a[:]# 将组合中的索引位置内容替换为 for index in comb:modified_list[index]  # print(f{modified_list})# print(fCombination: {[modified_list[i] for i in comb]}, Indices: {comb})l1.append(modified_list)# 输出组合的数量# print(l)   tf{hs}宫格 样式{a11:03} {x}空有{len(l1)}种print(f{hs}宫格 样式{a11:03} {x}空有{len(l1)}种)names.append(t)# 1空有9种# 2空有36种# 3空有84种# 4空有126种# 5空有126种# 6空有84种# 7空有36种# 8空有9种# 9空有1种nlen(combinations)# # 4宫格1套511种# print(n)    # 510# # 4宫格1套,12种图案每种510,共6132种# print(n*len(basis))#     print(n*576)# 将嵌套列表转换为扁平列表flat_list  [item for sublist in l1 for item in sublist]print(flat_list)print(len(flat_list))# 81# 将 flat_list 拆分成每组包含9个元素的嵌套列表grouped_list [flat_list[i:i  hs*hs] for i in range(0, len(flat_list),  hs*hs)]print(grouped_list)print(len(grouped_list))print(数字9个,grouped_list)styles1.append(grouped_list)# styles2.append(styles1)print(names)
print(len(names))
# 8种名称1-9
# 96种
# print(styles1)
# print(len(styles1)) # print(styles2)
# print(len(styles2))  
# 96种
# # 8种列表每种数量不等呈现正态分布    for nt in range(len(styles1)):# 按照样式1、2、3分组# wjoutput_dirfr\{hs}宫格 样式{nt:02}# os.makedirs(wj,exist_okTrue)for nr in range(len(styles1[nt])):# for ns in range(len(styles2[nt][nr])):tstyles1[nt][nr]print(t)# 设置画布参数rows  4cols  4cell_size  100border_width  10canvas_width  cols * cell_size  border_width * 2canvas_height  rows * cell_size  border_width * 2# 加载字体font_path  rC:\Windows\Fonts\arial.ttf  # 替换成你的字体文件路径font_size  60font  ImageFont.truetype(font_path, font_size)# 创建图像canvas_color  (255, 255, 255)  # 白色image  Image.new(RGB, (canvas_width, canvas_height), canvas_color)draw  ImageDraw.Draw(image)# 绘制边框draw.rectangle([(0, 0), (canvas_width, canvas_height)], outline(0, 0, 0), widthborder_width)# 计算内部区域的起始点和结束点inner_start_x  border_widthinner_end_x  canvas_width - border_widthinner_start_y  border_widthinner_end_y  canvas_height - border_width# 绘制表格去掉边框线10磅for row in range(rows  1):start_y  inner_start_y  row * cell_sizedraw.line((inner_start_x, start_y, inner_end_x, start_y), fill(0, 0, 0))  # 水平线for col in range(cols  1):start_x  inner_start_x  col * cell_sizedraw.line((start_x, inner_start_y, start_x, inner_end_y), fill(0, 0, 0))  # 垂直线    # 在每个单元格的中心点写入数字for row in range(rows):for col in range(cols):index  row * cols  colnumber  t[index]text  str(number)text_width, text_height  draw.textsize(text, fontfont)center_x  inner_start_x  col * cell_size  (cell_size - text_width) // 2center_y  inner_start_y  row * cell_size  (cell_size - text_height) // 2 - 10# 绘制数字draw.text((center_x, center_y), text, fontfont, fill(0, 0, 0))# 绘制下划线underline_y  center_y  text_height // 1  10  # 调整下划线位置使其位于数字下方draw.line((center_x - text_width //10, underline_y, center_x  text_width *1, underline_y), fill(0, 0, 0), width2)# 保存图像output_path  os.path.join(output_dir, f{names[nt]} {nr1:05}.png)image.save(output_path)print(fImage saved to {output_path})# 每510张打包再一起,样式1 510张、样式2 510张、样式3 510张  
import os
import shutil# 设置源文件夹路径
source_folder  output_dir
print(source_folder)# C:\Users\jg2yXRZ\OneDrive\桌面\20250311 4宫格所有可能图片版\01三宫格图片版\00全部hs  4  # Assuming hs is defined somewhere in your code
# path  your_path  # Replace with your actual path# 创建目标文件夹
for i in range(1, int(len(basis)  1)):  # 假设总共有30个文件分成3组folder_name  os.path.join(path, f{hs}宫格 样式{i:03})os.makedirs(folder_name, exist_okTrue)# 获取所有图片文件名
image_files  [f for f in os.listdir(source_folder) if f.endswith((.png, .jpg, .jpeg))]# 分组并复制文件 n510
group_size  n
for i, file in enumerate(image_files):group_index  i // group_size  1  # 计算当前文件属于第几组source_path  os.path.join(source_folder, file)destination_path  os.path.join(path, f{hs}宫格 样式{group_index:05}, file)shutil.copy(source_path, destination_path)print(fCopied {file} to {destination_path})# 记录程序结束时间
end_time  datetime.now()# 计算程序运行时间
elapsed_time  end_time - start_timeprint(f数独{hs}宫格程序开始时间:{start_time})
print(f数独{hs}宫格程序结束时间:{end_time})# 打印程序运行时间
print(程序运行时间, elapsed_time) 这个4宫格有576套现在正在获取所有的全部图片电脑啸叫厉害估计要内存不够了