Chatgpt

Chatgpt 이용한 프로그램 짜기 4 - 파이썬(QR코드 생성)

code2772 2023. 7. 18. 05:40
728x90
반응형

✔ gpt입력 내용 :
Python에서 QR 코드를 생성하는 코드 작성해줘
 

import qrcode

def generate_qr_code(data, filename):
    qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
    qr.add_data(data)
    qr.make(fit=True)

    qr_image = qr.make_image(fill_color="black", back_color="white")
    qr_image.save(filename)

data = "https://www.example.com"
filename = "qr_code.png"

generate_qr_code(data, filename)

 
✔ gpt입력 내용 :
Python에서 QR 코드를 생성하는 코드를 작성합니다. 04.QR코드 생성기 폴더에 저장되도록 이미지 파일이 저장되는 위치를 적어줘
 

import qrcode
import os

def generate_qr_code(data, filename):
    qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
    qr.add_data(data)
    qr.make(fit=True)

    qr_image = qr.make_image(fill_color="black", back_color="white")

    output_dir = "04.QR code generator"
    os.makedirs(output_dir, exist_ok=True)

    output_path = os.path.join(output_dir, filename)
    qr_image.save(output_path)
    print(f"QR code image saved at: {output_path}")

data = "https://www.example.com"
filename = "qr_code.png"

generate_qr_code(data, filename)

 
✔ gpt입력 내용 :
04. QR 코드 생성기 폴더의 qrdata.txt 파일에서 데이터를 QR 코드로 만든다. 04.QR코드 생성기 폴더에 저장되도록 이미지 파일이 저장되는 위치를 적어줘
 

import psutil
import time

def monitor_system():
    while True:
        cpu_percent = psutil.cpu_percent(interval=1)
        ram_usage = psutil.virtual_memory().percent
        network_stats = psutil.net_io_counters()
        network_sent = network_stats.bytes_sent
        network_recv = network_stats.bytes_recv

        print(f"CPU Usage: {cpu_percent}%")
        print(f"RAM Usage: {ram_usage}%")
        print(f"Network Sent: {network_sent} bytes")
        print(f"Network Received: {network_recv} bytes")
        print("")

        time.sleep(1)

monitor_system()

반응형