【教学类-43-26】20240312 数独4宫格的所有可能(图片版 576套样式,空1格-空8格,每套65534张*576小图=3千万张小图)

news2025/3/16 2:49:15

背景需求:

之前做了三宫格所有可能图片 510小图*12套=6120图,所以3分钟就生成了

【教学类-43-25】20240311 数独3宫格的所有可能(图片版 12套样式,空1格-空8格,每套510张,共6120小图)-CSDN博客文章浏览阅读663次,点赞12次,收藏11次。【教学类-43-25】20240311 数独3宫格的所有可能(图片版 12套样式,空1格-空8格,每套510张,共6120小图) https://blog.csdn.net/reasonsummer/article/details/146190184?spm=1011.2415.3001.5331

现在我想制作四宫格的所有图片,已知四宫格的数量是三个格的指数倍数。

把3宫格代码修改一下,做 一套4宫格所有可能(图片版)


'''
目的:数独4宫格,所有可能样式,做成图片(调整下划线位置
作者:阿夏
时间:20250311


'''

import 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 datetime

from PIL import Image, ImageDraw, ImageFont
import os
import copy


# 开始时间
start_time = datetime.now()

# 制作"单元格"# 几宫格
hs=4
# int(input('4宫格数独=3\n'))
# 内容太多了,容易报错,如果报错,就重新设置起始宫格数字1-8
start=1
# 第几套,第一套

# 新建一个”装N份word和PDF“的临时文件夹
# 创建输出目录
path = r'C:\Users\jg2yXRZ\OneDrive\桌面\20250311 4宫格所有可能(图片版)\01四宫格图片版'
os.makedirs(path, exist_ok=True)
output_dir = path + r'\00全部'
os.makedirs(output_dir, exist_ok=True)
      


print('------第2步:制作4宫格的12套题的内容-------')

# 制作4宫格的12套题目(没有空格,只有基础模板)
lst=[]
for b in range(1,hs+1):
    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))
# 1080

v=hs*hs
# 9个数字抽取一组
f=[]
for i in range(int(len(ll)/v)):
    f.append(ll[i*v:i*v+v])
# 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, 4, 1, 2, 2, 3, 4, 1, 4, 1, 2, 3]
# [1, 2, 3, 4, 3, 4, 1, 2, 4, 1, 2, 3, 2, 3, 4, 1]
# [1, 2, 3, 4, 3, 4, 1, 2, 4, 3, 2, 1, 2, 1, 4, 3]
# [1, 2, 3, 4, 3, 4, 2, 1, 2, 1, 4, 3, 4, 3, 1, 2]
# [1, 2, 3, 4, 3, 4, 2, 1, 4, 3, 1, 2, 2, 1, 4, 3]
# [1, 2, 3, 4, 4, 1, 2, 3, 2, 3, 4, 1, 3, 4, 1, 2]
# [1, 2, 3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 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道题目

jc=path+fr'\{hs}宫格 基础{int(len(basis))}种'
os.makedirs(jc,exist_ok=True)

# 制作12张原始基础样式
for n2 in range(len(basis)):
    # for ns in range(len(styles2[nt][nr])):
    t2=basis[n2]
    print(t2)

    # 设置画布参数
    rows = 4
    cols = 4
    cell_size = 100
    border_width = 10
    canvas_width = cols * cell_size + border_width * 2
    canvas_height = rows * cell_size + border_width * 2

    

    # 加载字体
    font_path = r'C:\Windows\Fonts\arial.ttf'  # 替换成你的字体文件路径
    font_size = 60
    font = 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), width=border_width)

    # 计算内部区域的起始点和结束点
    inner_start_x = border_width
    inner_end_x = canvas_width - border_width
    inner_start_y = border_width
    inner_end_y = canvas_height - border_width

    # 绘制表格(去掉边框线10磅)
    for row in range(rows + 1):
        start_y = inner_start_y + row * cell_size
        draw.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_size
        draw.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 + col
            number = t2[index]
            text = str(number)
            text_width, text_height = draw.textsize(text, font=font)
            center_x = inner_start_x + col * cell_size + (cell_size - text_width) // 2
            center_y = inner_start_y + row * cell_size + (cell_size - text_height) // 2 - 10
            
            # 绘制数字
            draw.text((center_x, center_y), text, font=font, 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), width=2)

    
    
    # 保存图像
    output_path1 = os.path.join(jc, f'{hs}宫格 基础样式{n2+1:03}.png')
    image.save(output_path1)
    print(f"Image saved to {output_path1}")

print('---------第3步,原始列表生成样式1,了解数量和空格位置----------')
# 读取每一款,假设任意缺1空、任意缺2空,任意缺三空
# 原始列表
import itertools
m=1

names=[]
styles1=[]
styles2=[]

for a1 in  range(len(basis)):   
    a=basis[a1]
    print(a)
    # [1, 2, 3, 2, 3, 1, 3, 1, 2]
    
    # 12张一页的样式
    n=0
    xx=0
    
    for 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(f"Combination: {[modified_list[i] for i in comb]}, Indices: {comb}")
            l1.append(modified_list)
        # 输出组合的数量
        # print(l)   
        t=f"{hs}宫格 样式{a1+1:03} {x}空有{len(l1)}种"
        print(f"{hs}宫格 样式{a1+1: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种
        n+=len(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分组
    # wj=output_dir+fr'\{hs}宫格 样式{nt:02}'
    # os.makedirs(wj,exist_ok=True)

    for nr in range(len(styles1[nt])):
        # for ns in range(len(styles2[nt][nr])):
        t=styles1[nt][nr]
        print(t)

        # 设置画布参数
        rows = 4
        cols = 4
        cell_size = 100
        border_width = 10
        canvas_width = cols * cell_size + border_width * 2
        canvas_height = rows * cell_size + border_width * 2

        

        # 加载字体
        font_path = r'C:\Windows\Fonts\arial.ttf'  # 替换成你的字体文件路径
        font_size = 60
        font = 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), width=border_width)

        # 计算内部区域的起始点和结束点
        inner_start_x = border_width
        inner_end_x = canvas_width - border_width
        inner_start_y = border_width
        inner_end_y = canvas_height - border_width

        # 绘制表格(去掉边框线10磅)
        for row in range(rows + 1):
            start_y = inner_start_y + row * cell_size
            draw.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_size
            draw.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 + col
                number = t[index]
                text = str(number)
                text_width, text_height = draw.textsize(text, font=font)
                center_x = inner_start_x + col * cell_size + (cell_size - text_width) // 2
                center_y = inner_start_y + row * cell_size + (cell_size - text_height) // 2 - 10
                
                # 绘制数字
                draw.text((center_x, center_y), text, font=font, 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), width=2)
    
       

        # 保存图像
        output_path = os.path.join(output_dir, f'{names[nt]} {nr+1:05}.png')
        image.save(output_path)
        print(f"Image 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_ok=True)

# 获取所有图片文件名
image_files = [f for f in os.listdir(source_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]

# 分组并复制文件 n=510
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(f"Copied {file} to {destination_path}")


# 记录程序结束时间
end_time = datetime.now()

# 计算程序运行时间
elapsed_time = end_time - start_time

print(f"数独{hs}宫格程序开始时间:{start_time}")
print(f"数独{hs}宫格程序结束时间:{end_time}")

# 打印程序运行时间
print("程序运行时间:", elapsed_time)

这个4宫格有576套,现在正在获取所有的全部图片,电脑啸叫厉害,估计要内存不够了。

结果:生成了大约1小时,VScode自动关闭了,半夜我又试了一次,还是如此。

因此我想测试576种的任意1套有多少种可能。

大约生成了20分钟。576套就是11520分钟等于192小时(4宫格的用时,就已经要疯掉)

图片效果

一套题,65534张。

原来,65534*576=37747584(3774万),数量太多了,难怪VScode内存不够,自动关闭了。

图片长宽

图片大小

总内存(65534张图片一共521MB 乘以576套等于MB)

521*576=300096 MB/1024MG 等于 292.875 GB。

我的电脑都没有这么多的空间,(灬ꈍ ꈍ灬)

因为这套是图片版本,所以不能像WORD版本那样对地一套题目的数字进行替换(文字数字可以替换),这里只能逐步生成576套题。

——唉,内存装不下这么多图片,只能返回先把3宫格6012题做WORD和PDF。或者先把样式1的4万张做成PDF,删除图片后,再生成第二套。总之也是漫长的制作过程啊。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2315757.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何手动使用下载并且运行 QwQ-32B-GGUF

首先使用安装 pip install ModelScope 使用 ModelScope 下载对应的模型 modelScope download --model Qwen/QwQ-32B-GGUF qwq-32b-q4_k_m.gguf 第二步开始下载 ollama git clone https://githubfast.com/ggerganov/llama.cpp # githubfast.com 可以加速下载 切换到目录&am…

Spring Boot对接twilio发送邮件信息

要在Spring Boot应用程序中对接Twilio发送邮件信息,您可以使用Twilio的SendGrid API。以下是一个简单的步骤指南,帮助您完成这一过程: 1. 创建Twilio账户并获取API密钥 注册一个Twilio账户(如果您还没有的话)。在Twi…

约束优化技术:KKT条件的完整推导与应用

前言 本文隶属于专栏《机器学习数学通关指南》,该专栏为笔者原创,引用请注明来源,不足和错误之处请在评论区帮忙指出,谢谢! 本专栏目录结构和参考文献请见《机器学习数学通关指南》 ima 知识库 知识库广场搜索&#…

对比文章相似度的余弦相似度算法的原理

近期不是项目遇到对比代码的相似度,来判断代码是否存在抄袭嘛。通过研究采用了余弦相似度来对比。既然接触的一个新的东西,怎么也得研究下吧。 一、什么是余弦相似度 利用余弦相似度对比文章相似度的原理,主要基于向量空间模型,通…

DeepSeek结合Mermaid绘图(流程图、时序图、类图、状态图、甘特图、饼图)转载

思维速览: 本文将详细介绍如何利用DeepSeek结合Mermaid语法绘制各类专业图表,帮助你提高工作效率和文档质量。 ▍DeepSeek入门使用请看:deepseek保姆级入门教程(网页端使用 本地客户端部署 使用技巧) DeepSeek官网…

玩转云服务器——阿里云操作系统控制台体验测评

在云服务器日益普及的背景下,运维人员对操作系统管理工具的要求不断提高。我们需要一款既能直观展示系统状态,又能智能诊断问题,提供专业指导的控制台。阿里云操作系统管理平台正是基于API、SDK、CLI等多种管理方式,致力于提升操作…

Linux 安装 Oh My Zsh

1. 简介 Zsh(Z Shell)是一款功能强大的 Shell,相比 Bash 提供了更强的 自动补全、命令高亮、插件支持 等功能。而 Oh My Zsh 是一个 Zsh 的增强管理工具,让你可以轻松安装插件和主题,极大提高开发效率。 本教程将详细…

方差,协方差及协方差矩阵的计算

1.方差 方差是用来衡量一组数据的离散程度,数序表达式如下: σ 2 1 N ∑ i 1 N ( x i − μ ) 2 \sigma^2\frac1N\sum_{i1}^N(x_i-\mu)^2 σ2N1​i1∑N​(xi​−μ)2 σ 2 σ^2 σ2表示样本的总体方差, N N N 表示样本总数, x i x _i xi​…

DeepSeek-R1思路训练多模态大模型-Vision-R1开源及实现方法思路

刚开始琢磨使用DeepSeek-R1风格训练多模态R1模型,就看到这个工作,本文一起看看,供参考。 先提出问题,仅靠 RL 是否足以激励 MLLM 的推理能力? 结论:不能,因为如果 RL 能有效激励推理能力&#…

Unity 创建签名证书、获取签名证书信息,证书指纹

目录 一:创建签名证书 二:自动填写密码 ​编辑 三:获取签名证书的信息 后言 👑👑👑 一:创建签名证书 首先确保Unity是安卓打包,然后按图操作 会打开下图页面 选择你要创建到的…

在AIStudio飞桨星河社区一键部署DeepSeek-r1:70b模型

随着DeepSeek的火热,市面上出现大量的第三方的API服务区,但是对于对安全、隐私、控制有一定需求的用户,还是会希望能够自主部署DeepSeek 。 实践下来,用自己的机器部署是一条解决之道,但是推理起来,cpu和内…

机器学习算法分类及应用场景全解析

在机器学习的学习过程中,具备归类思想至关重要。机器学习涉及众多算法、数据类型及应用场景,归类能让我们清晰梳理知识体系。比如将算法按学习方式分为有监督、无监督等,按任务分类分为分类任务、回归任务和生成任务。通过归类,能…

GNU Nano编辑器中,怎样保存并退出

当出现git commit的提交内容需要修改时,使用git commit --amend进行解决。 但是在修改提交的内容时,弹出了GNU Nano的编辑器 修改完毕后,使用ctrlxd的组合键退出 输入Y后,将退出编辑器,操作完成

个人居家 Web移动端 局域网 远程控制电脑 工具 PC遥控器拿去玩吧

想远程电脑 换个电影,切个歌,随有无线键鼠,但解决不了离屏幕较远 看不清鼠标指针和键入内容。 看似简单的事情,但对周末躺下沙发的码农来说,就再也起不了身了。 远程工具 TeamViewer、向日葵、Autodesk以及开源的RustD…

cursor中使用prettier-code formatter插件方法

cursor的"扩展"中搜索"prettier-code formatter",然后安装 点击cursor编辑器右上角“更多操作”,然后打开“配置编辑器” 按照图片进行操作,进入到editor在editor中,找“格式化“,把Format On Sav…

SpaceSync智能排班:重构未来办公空间的神经中枢

文心智能体平台可免费使用DeepSeek 满血版啦,使用DeepSeek模型创建并提交智能体,即有机会瓜分万元奖金!有这等好事还不快冲! 文心智能体官网:文心智能体平台AgentBuilder | 想象即现实 本片文章为作者参加文心智能体平…

ToB公司找客户专用|大数据获客系统

对于ToB公司而言,找到并吸引合适的潜在客户并非易事。传统的获客手段如参加行业展会、电话推销以及直接拜访等,虽然在过去取得了一定成效,但如今却暴露出诸多问题。首先,这些方法往往成本高昂,无论是时间还是金钱上的投…

Linux 文件权限类

目录 文件属性 从左到右的10个字符表示 rwx作用文件和目录的不同解释 图标: 案例实操 chmod 改变权限 基本语法 经验技巧 案例实操 拓展:可以通过一个命令查看用户列表 chown改变所有者 基本语法 选项说明 案例实操 chgrp 改变所属组 基…

在线Doc/Docx转换为PDF格式 超快速转换的一款办公软件 文档快速转换 在线转换免费转换办公软件

小白工具https://www.xiaobaitool.net/files/word-pdf/提供了一项非常实用的在线服务——将Doc或Docx格式的文档快速转换为PDF格式。这项服务不仅操作简单,而且转换效率高,非常适合需要频繁处理文档转换的用户。 服务特点: 批量转换&#x…

网络安全——SpringBoot配置文件明文加密

XTHS:第一步、XTHS:第二步、XTHS:第三步、XTHS:第四步 !就可以实现了。(但是前提,你要先对你的文本进行加密,然后按照ENC(加密文本),放到配置文件中) 一、前言…