”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > 使用自然语言通过法学硕士生成简单的 Python GUI .... 在不到几分钟的时间内

使用自然语言通过法学硕士生成简单的 Python GUI .... 在不到几分钟的时间内

发布于2024-11-02
浏览:939

Thought that building Python GUIs took hours of tedious coding?

Welcome to an exciting new era!

Not only can tools like Github Copilot help with code fixing, linting, and generation, but you can simply provide an entire spec to an LLM and ask it to generate a GUI (or a CLI) for you.

I've been trying out GPT-4o, Claude Sonnet 3.5 and Code Llama 70B available from Anyscale.

While the GUIs aren't always beautiful (see what I created today and 'Daniel's Workstation Genie') they're typically fully functional.

Below is a full prompt and output chain using GPT 4o and Claude Sonnet 3.5 to define a spec, debug, and iterate feature additions.

The entire process from defining the GUI to validating its first use took less than 15 minutes.

Prompt 1 Defining Specs To GPT 4o

Please generate an impressive and nicely designed GUI for generating images from prompts in a repo.

My openAI key is OPENAI_KEY in the dot env file

The GUI should allow the user to specify a title for the image and a prompt and a size that the image should be in pixels

The user should also be able to specify where the generated image should be stored in their OS

his setting should persist through reboots, so it will be to be saved into some kind of non-volatile storage

Once the user has entered the prompt and any other parameters that they might wish to adjust, the generation request is sent to the DALLE API

The file should be saved into a subfolder immediately within the output directory that the user specified.

The subfolder should be in the format ddmmyy.

If it does not already exist, it should be created

he file name is the title that the user configured If the user chose a title "Smiling sloth at computer" the file name would be smiling-sloth-at-computer.webp

The GUI should be nicely designed with clear buttons and a bright UI


Output 1 By GPT-4 Omni

Here's a Python script using PyQt6 to create an impressive and nicely designed GUI for generating images from prompts using the DALL-E API. This script allows users to specify a title, prompt, image size, and output directory. The settings persist through reboots using QSettings.

import sys
import os
import requests
from datetime import datetime
from PyQt6.QtWidgets import (QApplication, QWidget, QVBoxLayout, QLabel, 
                             QLineEdit, QPushButton, QFileDialog, QMessageBox,
                             QComboBox)
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt, QSettings
from dotenv import load_dotenv
import openai

# Load the OpenAI API key from the .env file
load_dotenv()
api_key = os.getenv('OPENAI_KEY')
openai.api_key = api_key

class DalleImageGenerator(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('DALL-E Image Generator')
        self.setGeometry(100, 100, 500, 300)
        self.setStyleSheet("background-color: #f0f8ff;")  # Light blue background

        layout = QVBoxLayout()

        # Title input
        title_label = QLabel('Image Title:')
        self.title_input = QLineEdit()
        layout.addWidget(title_label)
        layout.addWidget(self.title_input)

        # Prompt input
        prompt_label = QLabel('Enter your prompt:')
        self.prompt_input = QLineEdit()
        layout.addWidget(prompt_label)
        layout.addWidget(self.prompt_input)

        # Size selection
        size_label = QLabel('Select Image Size:')
        self.size_combo = QComboBox()
        self.size_combo.addItems(["256x256", "512x512", "1024x1024"])
        layout.addWidget(size_label)
        layout.addWidget(self.size_combo)

        # Output folder selection
        folder_layout = QVBoxLayout()
        self.folder_label = QLabel('Select output folder:')
        self.folder_button = QPushButton('Browse')
        self.folder_button.clicked.connect(self.select_folder)
        folder_layout.addWidget(self.folder_label)
        folder_layout.addWidget(self.folder_button)
        layout.addLayout(folder_layout)

        # Generate button
        generate_button = QPushButton('Generate Image')
        generate_button.setStyleSheet('background-color: #4682b4; color: white;')  # Steel blue button
        generate_button.clicked.connect(self.generate_image)
        layout.addWidget(generate_button)

        self.setLayout(layout)

        # Load saved settings
        self.settings = QSettings('DalleImageGenerator', 'Settings')
        self.load_settings()

    def select_folder(self):
        folder = QFileDialog.getExistingDirectory(self, "Select Directory")
        if folder:
            self.folder_label.setText(f'Selected: {folder}')
            self.settings.setValue('output_folder', folder)

    def load_settings(self):
        output_folder = self.settings.value('output_folder', '')

        if output_folder:
            self.folder_label.setText(f'Selected: {output_folder}')

    def save_settings(self):
        self.settings.setValue('output_folder', self.settings.value('output_folder', ''))

    def generate_image(self):
        title = self.title_input.text().strip().replace(" ", "-").lower()
        prompt = self.prompt_input.text().strip()

        if not title or not prompt:
            QMessageBox.warning(self, 'Error', 'Please enter both a title and a prompt.')
            return

        size = self.size_combo.currentText()

        try:
            # Call the DALL-E API to generate an image
            response = openai.Image.create(
                prompt=prompt,
                n=1,
                size=size
            )

            image_url = response['data'][0]['url']

            # Create the directory structure if it doesn't exist
            today = datetime.now().strftime('%d%m%y')
            output_folder = self.settings.value('output_folder', '')
            save_path = os.path.join(output_folder, today)
            os.makedirs(save_path, exist_ok=True)

            # Download and save the image
            image_response = requests.get(image_url)
            image_path = os.path.join(save_path, f'{title}.webp')

            with open(image_path, 'wb') as f:
                f.write(image_response.content)

            QMessageBox.information(self, 'Success', f'Image saved to {image_path}')
            self.close()

        except Exception as e:
            QMessageBox.critical(self, 'Error', f'An error occurred: {str(e)}')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon())  # Add your icon here if available
    ex = DalleImageGenerator()
    ex.show()
    sys.exit(app.exec())

Key Features:

  • User Inputs: Allows users to specify an image title, prompt, and size.
  • Output Directory: Users can select an output directory for saving images. This setting persists through reboots using QSettings.
  • Folder Structure: Images are saved in /generations/ddmmyy format within the specified output directory.
  • File Naming: The file name is based on the user-provided title (converted to lowercase and spaces replaced with hyphens).
  • Bright UI: The interface uses a light blue background with steel blue buttons for a modern look.

Setup Instructions:

  1. Install Required Packages: Ensure you have these packages installed:
   pip install pyqt6 openai python-dotenv requests
  1. Create a .env File: Place your OpenAI API key in a .env file in the same directory as the script:
   OPENAI_KEY=your_openai_api_key_here
  1. Run the Script: Execute the script to launch the GUI and start generating images.

This GUI provides a user-friendly interface for generating images with DALL-E while managing settings efficiently.


Prompt 2

Is it not possible to choose a custom image size when using the API? I see that you've decided to allow 3 variables, but in most cases I'd like to specify a custom size. If it's possible, the user should be able to choose a custom size rather than any variables. If that's not a possible feature, remove the selection functionality from the UI altogether


Output 2 - GPT4o Mini

Based on the information from the search results, DALL-E 3 currently supports three predefined image sizes: 1024x1024, 1792x1024, and 1024x1792 pixels[1][2][3]. Custom image sizes are not supported directly through the API. Therefore, you should remove the custom size selection functionality from the UI and instead provide a dropdown with these three options.

Here's how you can update the GUI to reflect this:

import sys
import os
import requests
from datetime import datetime
from PyQt6.QtWidgets import (QApplication, QWidget, QVBoxLayout, QLabel, 
                             QLineEdit, QPushButton, QFileDialog, QMessageBox,
                             QComboBox)
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt, QSettings
from dotenv import load_dotenv
import openai

# Load the OpenAI API key from the .env file
load_dotenv()
api_key = os.getenv('OPENAI_KEY')
openai.api_key = api_key

class DalleImageGenerator(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('DALL-E Image Generator')
        self.setGeometry(100, 100, 500, 300)
        self.setStyleSheet("background-color: #f0f8ff;")  # Light blue background

        layout = QVBoxLayout()

        # Title input
        title_label = QLabel('Image Title:')
        self.title_input = QLineEdit()
        layout.addWidget(title_label)
        layout.addWidget(self.title_input)

        # Prompt input
        prompt_label = QLabel('Enter your prompt:')
        self.prompt_input = QLineEdit()
        layout.addWidget(prompt_label)
        layout.addWidget(self.prompt_input)

        # Size selection
        size_label = QLabel('Select Image Size:')
        self.size_combo = QComboBox()
        self.size_combo.addItems(["1024x1024", "1792x1024", "1024x1792"])
        layout.addWidget(size_label)
        layout.addWidget(self.size_combo)

        # Output folder selection
        folder_layout = QVBoxLayout()
        self.folder_label = QLabel('Select output folder:')
        self.folder_button = QPushButton('Browse')
        self.folder_button.clicked.connect(self.select_folder)
        folder_layout.addWidget(self.folder_label)
        folder_layout.addWidget(self.folder_button)
        layout.addLayout(folder_layout)

        # Generate button
        generate_button = QPushButton('Generate Image')
        generate_button.setStyleSheet('background-color: #4682b4; color: white;')  # Steel blue button
        generate_button.clicked.connect(self.generate_image)
        layout.addWidget(generate_button)

        self.setLayout(layout)

        # Load saved settings
        self.settings = QSettings('DalleImageGenerator', 'Settings')
        self.load_settings()

    def select_folder(self):
        folder = QFileDialog.getExistingDirectory(self, "Select Directory")
        if folder:
            self.folder_label.setText(f'Selected: {folder}')
            self.settings.setValue('output_folder', folder)

    def load_settings(self):
        output_folder = self.settings.value('output_folder', '')

        if output_folder:
            self.folder_label.setText(f'Selected: {output_folder}')

    def save_settings(self):
        self.settings.setValue('output_folder', self.settings.value('output_folder', ''))

    def generate_image(self):
        title = self.title_input.text().strip().replace(" ", "-").lower()
        prompt = self.prompt_input.text().strip()

        if not title or not prompt:
            QMessageBox.warning(self, 'Error', 'Please enter both a title and a prompt.')
            return

        size = self.size_combo.currentText()

        try:
            # Call the DALL-E API to generate an image
            response = openai.Image.create(
                prompt=prompt,
                n=1,
                size=size
            )

            image_url = response['data'][0]['url']

            # Create the directory structure if it doesn't exist
            today = datetime.now().strftime('%d%m%y')
            output_folder = self.settings.value('output_folder', '')
            save_path = os.path.join(output_folder, today)
            os.makedirs(save_path, exist_ok=True)

            # Download and save the image
            image_response = requests.get(image_url)
            image_path = os.path.join(save_path, f'{title}.webp')

            with open(image_path, 'wb') as f:
                f.write(image_response.content)

            QMessageBox.information(self, 'Success', f'Image saved to {image_path}')
            self.close()

        except Exception as e:
            QMessageBox.critical(self, 'Error', f'An error occurred: {str(e)}')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon())  # Add your icon here if available
    ex = DalleImageGenerator()
    ex.show()
    sys.exit(app.exec())

Key Changes:

  • Size Selection: The size selection is now limited to the three available options: 1024x1024, 1792x1024, and 1024x1792 pixels.
  • Removed Custom Size Input: Since custom sizes are not supported by the API, this option has been removed from the UI.

This updated script maintains a user-friendly interface while adhering to the constraints of the DALL-E API.

Citations:
[1] https://webleveling.com/content-management/how-to-get-different-image-sizes-in-dalle-3/
[2] https://cookbook.openai.com/articles/what_is_new_with_dalle_3
[3] https://platform.openai.com/docs/guides/images


Prompt 3

Please add to the UI the ability to provide an open AI API key. once provided it should be saved in persistent storage along with the preferred output folder. there should be a save config button to allow the user to update these parameters from time to time and a "Config updated! success message when the configuration update is applied


Certainly! Here's an updated version of the script that includes the ability to input and save the OpenAI API key along with the preferred output folder. The configuration is saved using QSettings for persistence, and a "Config updated!" success message is displayed when the configuration is updated.

import sys
import os
import requests
from datetime import datetime
from PyQt6.QtWidgets import (QApplication, QWidget, QVBoxLayout, QLabel, 
                             QLineEdit, QPushButton, QFileDialog, QMessageBox,
                             QComboBox)
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import Qt, QSettings
import openai

class DalleImageGenerator(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle('DALL-E Image Generator')
        self.setGeometry(100, 100, 500, 400)
        self.setStyleSheet("background-color: #f0f8ff;")  # Light blue background

        layout = QVBoxLayout()

        # API Key input
        api_key_label = QLabel('OpenAI API Key:')
        self.api_key_input = QLineEdit()
        layout.addWidget(api_key_label)
        layout.addWidget(self.api_key_input)

        # Title input
        title_label = QLabel('Image Title:')
        self.title_input = QLineEdit()
        layout.addWidget(title_label)
        layout.addWidget(self.title_input)

        # Prompt input
        prompt_label = QLabel('Enter your prompt:')
        self.prompt_input = QLineEdit()
        layout.addWidget(prompt_label)
        layout.addWidget(self.prompt_input)

        # Size selection
        size_label = QLabel('Select Image Size:')
        self.size_combo = QComboBox()
        self.size_combo.addItems(["1024x1024", "1792x1024", "1024x1792"])
        layout.addWidget(size_label)
        layout.addWidget(self.size_combo)

        # Output folder selection
        folder_layout = QVBoxLayout()
        self.folder_label = QLabel('Select output folder:')
        self.folder_button = QPushButton('Browse')
        self.folder_button.clicked.connect(self.select_folder)
        folder_layout.addWidget(self.folder_label)
        folder_layout.addWidget(self.folder_button)
        layout.addLayout(folder_layout)

        # Save config button
        save_config_button = QPushButton('Save Config')
        save_config_button.setStyleSheet('background-color: #4682b4; color: white;')  # Steel blue button
        save_config_button.clicked.connect(self.save_settings)
        layout.addWidget(save_config_button)

        # Generate button
        generate_button = QPushButton('Generate Image')
        generate_button.setStyleSheet('background-color: #4682b4; color: white;')  # Steel blue button
        generate_button.clicked.connect(self.generate_image)
        layout.addWidget(generate_button)

        self.setLayout(layout)

        # Load saved settings
        self.settings = QSettings('DalleImageGenerator', 'Settings')
        self.load_settings()

    def select_folder(self):
        folder = QFileDialog.getExistingDirectory(self, "Select Directory")
        if folder:
            self.folder_label.setText(f'Selected: {folder}')
            self.settings.setValue('output_folder', folder)

    def load_settings(self):
        api_key = self.settings.value('api_key', '')
        output_folder = self.settings.value('output_folder', '')

        if api_key:
            self.api_key_input.setText(api_key)

        if output_folder:
            self.folder_label.setText(f'Selected: {output_folder}')

    def save_settings(self):
        api_key = self.api_key_input.text().strip()

        if not api_key:
            QMessageBox.warning(self, 'Error', 'Please enter your OpenAI API key.')
            return

        self.settings.setValue('api_key', api_key)

        QMessageBox.information(self, 'Config Updated', 'Configuration updated successfully!')

    def generate_image(self):
        title = self.title_input.text().strip().replace(" ", "-").lower()
        prompt = self.prompt_input.text().strip()

        if not title or not prompt:
            QMessageBox.warning(self, 'Error', 'Please enter both a title and a prompt.')
            return

        size = self.size_combo.currentText()

        try:
            openai.api_key = self.settings.value('api_key', '')

            if not openai.api_key:
                QMessageBox.warning(self, 'Error', 'OpenAI API key is missing. Please update your configuration.')
                return

            # Call the DALL-E API to generate an image
            response = openai.Image.create(
                prompt=prompt,
                n=1,
                size=size
            )

            image_url = response['data'][0]['url']

            # Create the directory structure if it doesn't exist
            today = datetime.now().strftime('%d%m%y')
            output_folder = self.settings.value('output_folder', '')
            save_path = os.path.join(output_folder, today)
            os.makedirs(save_path, exist_ok=True)

            # Download and save the image
            image_response = requests.get(image_url)
            image_path = os.path.join(save_path, f'{title}.webp')

            with open(image_path, 'wb') as f:
                f.write(image_response.content)

            QMessageBox.information(self, 'Success', f'Image saved to {image_path}')

            # Optionally close the application after success
            # self.close()

        except Exception as e:
            QMessageBox.critical(self, 'Error', f'An error occurred: {str(e)}')

if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon())  # Add your icon here if available
    ex = DalleImageGenerator()
    ex.show()
    sys.exit(app.exec())

Key Features:

  • API Key Input: Users can input their OpenAI API key directly into the GUI.
  • Persistent Storage: Both the API key and output folder are stored using QSettings, ensuring they persist through reboots.
  • Save Config Button: A button allows users to save their configuration settings. A success message confirms when settings are updated.
  • Generate Button: Generates images based on user input and saves them in a structured format.

Setup Instructions:

  1. Install Required Packages: Ensure you have these packages installed:
   pip install pyqt6 openai requests python-dotenv
  1. Run the Script: Execute the script to launch the GUI and start generating images.

This setup provides a complete solution for managing configurations and generating images with DALL-E through an intuitive interface.


Prompt 4 - Claude

Hi Claude. Please find attached a Python GUI that needs some debugging with the indentation. You can probably guess its purpose: it's to provide a simple GUI to allow the user run prompts for DALLE over the openAI API. It then saves them into a specified folder which the user can share.

In addition to the debugging, please make sure that the persistent storage is somewhere outside of the repo as I might choose to share this publicly at some point and I don't want to share my credentials (obviously).

Play around with the UI and color scheme too. It could use a lot of improvement. The green scheme that DALLE itself uses is nice and should be integrated.

Return the whole script in one code block without any comments. Validate it before returning it to me to make sure that it's valid executable Python that is free of errors.


Screenshots Of GUI Developed, Output 4

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

Using Natural Language To Generate A Simple Python GUI With An LLM .... In Less Than Minutes

版本声明 本文转载于:https://dev.to/danielrosehill/using-natural-language-to-generate-a-simple-python-gui-with-an-llm-3d7l?1如有侵犯,请联系[email protected]删除
最新教程 更多>
  • Hexabot 设置和可视化编辑器教程:构建您的第一个 AI 聊天机器人
    Hexabot 设置和可视化编辑器教程:构建您的第一个 AI 聊天机器人
    聊天机器人爱好者大家好!在本教程中,我们将指导您完成设置和使用开源 AI 聊天机器人构建器 Hexabot 的过程。我们将首先克隆 GitHub 存储库、安装依赖项并为 Hexabot 配置环境变量。您还将学习如何使用 Docker 启动项目、访问管理面板以及使用可视化编辑器创建聊天机器人流程。 在...
    编程 发布于2024-11-02
  • mysql_fetch_row()、mysql_fetch_assoc() 和 mysql_fetch_array():您应该选择哪一个?
    mysql_fetch_row()、mysql_fetch_assoc() 和 mysql_fetch_array():您应该选择哪一个?
    mysql_fetch_row()、mysql_fetch_assoc() 和 mysql_fetch_array() 解释背景:如果您正在使用已弃用的MySQL 扩展中,在从结果集中检索数据的 mysql_fetch_row()、mysql_fetch_assoc() 和 mysql_fetch_...
    编程 发布于2024-11-02
  • Next.js - 概述
    Next.js - 概述
    本文作为初学者友好的指南和使用 Next.js 的步骤。 Next.js 是一个用于构建 Web 应用程序的灵活框架。相反,它是一个构建在 Node.js 之上的 React 框架。 设置您的 Next.js 项目 要启动新的 Next.js 项目,您需要在计算机上安装 Node.js。 安装 安装...
    编程 发布于2024-11-02
  • 如何在代码中使用 Unsplash 图片
    如何在代码中使用 Unsplash 图片
    作为一名从事新 SaaS 项目的开发人员,我需要直接通过 URL 链接一些 Unsplash 图像。 最初,我看到一篇推荐使用 https://source.unsplash.com/ API 的文章(链接)。但是,此方法不再有效,并且仅从 URL 字段复制链接并不能提供嵌入所需的直接图像 URL...
    编程 发布于2024-11-02
  • 如何合并关联数组、处理缺失键以及填充默认值?
    如何合并关联数组、处理缺失键以及填充默认值?
    合并多个关联数组并添加具有默认值的缺失列将关联数组与不同的键集组合起来创建统一的数组可能具有挑战性。这个问题探索了一种实现此目的的方法,所需的输出是一个数组,其中键被合并,缺失的列用默认值填充。为了实现这一点,建议结合使用 array_merge 函数精心设计的键数组:$keys = array()...
    编程 发布于2024-11-02
  • 通过 testcontainers-go 和 docker-compose 来利用您的测试套件
    通过 testcontainers-go 和 docker-compose 来利用您的测试套件
    Welcome back, folks! Today, we will cover the end-to-end tests in an intriguing blog post. If you've never written these kinds of tests or if you stri...
    编程 发布于2024-11-02
  • 以下是一些适合您文章的基于问题的标题:

**直接简洁:**

* **如何在Windows控制台中正确显示UTF-8字符?**
* **为什么传统方法无法显示
    以下是一些适合您文章的基于问题的标题: **直接简洁:** * **如何在Windows控制台中正确显示UTF-8字符?** * **为什么传统方法无法显示
    在 Windows 控制台中正确显示 UTF-8 字符使用传统方法在 Windows 控制台中显示 UTF-8 字符的许多尝试均失败正确渲染扩展字符。失败的尝试:使用 MultiByteToWideChar() 和 wprintf() 的一种常见方法被证明是无效的,只留下 ASCII 字符可见。此外...
    编程 发布于2024-11-02
  • ReactJS 的模拟介绍
    ReactJS 的模拟介绍
    ReactJS 19:重要部分 并发模式增强: ReactJS 19 中最大的改进是并发模式,它不仅在应用程序自身更新时保持 UI 平滑和响应灵敏,而且还确保了无缝界面,尤其是在复杂的过渡(例如动画)时。 改进的服务器组件: 在 Python 的引领下,ReactJ...
    编程 发布于2024-11-02
  • 首届DEV网页游戏挑战赛评委
    首届DEV网页游戏挑战赛评委
    我被要求对DEV团队9月份组织的第一届网页游戏挑战赛提交的参赛作品进行评判,结果在10月初发布。 我们几个月来一直在 DEV 上组织挑战(迷你黑客马拉松),并计划宣布我们的第一个网页游戏挑战。鉴于您在游戏社区 和 dev.to 的专业知识和参与度,我们想知道您是否有兴趣成为客座评委。 谁能对此说“不...
    编程 发布于2024-11-02
  • 购买经过验证的现金应用程序帐户:安全可靠的交易
    购买经过验证的现金应用程序帐户:安全可靠的交易
    Buying verified Cash App accounts is not recommended. It can lead to security risks and potential account bans. If you want to more information just k...
    编程 发布于2024-11-02
  • 为什么 `std::function` 缺乏相等比较?
    为什么 `std::function` 缺乏相等比较?
    揭开 std::function 的等式可比性之谜难题:为什么是 std::function,现代 C 代码库的一个组成部分,不具备相等比较功能?这个问题从一开始就困扰着程序员,导致管理可调用对象集合的混乱和困难。早期的歧义:在 C 语言的早期草案中11 标准中,operator== 和operat...
    编程 发布于2024-11-02
  • JavaScript 类型检查 |编程教程
    JavaScript 类型检查 |编程教程
    介绍 本文涵盖以下技术技能: 在本实验中,我们将探索一个 JavaScript 函数,该函数检查提供的值是否属于指定类型。我们将使用 is() 函数,它利用构造函数属性和 Array.prototype.includes() 方法来确定值是否属于指定类型。本实验将帮助您更好地了解 ...
    编程 发布于2024-11-02
  • 使用 Streamlit 将机器学习模型部署为 Web 应用程序
    使用 Streamlit 将机器学习模型部署为 Web 应用程序
    介绍 机器学习模型本质上是一组用于进行预测或查找数据模式的规则或机制。简单地说(不用担心过于简单化),在 Excel 中使用最小二乘法计算的趋势线也是一个模型。然而,实际应用中使用的模型并不那么简单——它们通常涉及更复杂的方程和算法,而不仅仅是简单的方程。 在这篇文章中,我将首先构...
    编程 发布于2024-11-02
  • ## utf8_unicode_ci 与 utf8_bin:哪种 MySQL 排序规则最适合德国网站?
    ## utf8_unicode_ci 与 utf8_bin:哪种 MySQL 排序规则最适合德国网站?
    为德语选择最佳 MySQL 排序规则在设计为德语受众量身定制的网站时,支持像 ä、 ü 和 ß。当涉及特定于语言的要求时,排序规则的选择起着重要作用。字符集和排序规则对于字符处理,UTF-8 仍然是首选选项,提供广泛的字符支持。至于排序规则,需要考虑德语特定字符。排序规则类型MySQL 提供各种排序...
    编程 发布于2024-11-02
  • 异常处理基础知识
    异常处理基础知识
    Java中的异常处理由五个关键字管理:try、catch、 throw、throws和finally。 这些关键字构成了一个相互关联的子系统。 要监视的指令位于 try 块内。 如果try块中发生异常,则会抛出异常。 代码可以使用catch捕获并处理异常。 系统异常由Java运行时自动抛出。 要手...
    编程 发布于2024-11-02

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3