Sign In

๐Ÿ“์•Œ๋ฐ” ํ›„๊ธฐ/์ถ”์ฒœ

์•„๋ฅด๋ฐ”์ดํŠธ์˜ ํ›„๊ธฐ ๋˜๋Š” ์ถ”์ฒœ ๋ฆฌ์ŠคํŠธ๋ฅผ ์•„๋ž˜์˜ ๋งํฌ๋ฅผ ํƒ€๊ณ  ๋“ค์–ด๊ฐ€ ์ ์–ด์ฃผ์„ธ์š”!

์‹ค์ œ ๊ทผ๋ฌดํ•œ ํ•™์ƒ๋“ค์˜ ์†”์งํ•œ ํ›„๊ธฐ์™€ ์ถ”์ฒœ ์•Œ๋ฐ”๋ฅผ ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.
์ข‹์€ ์•Œ๋ฐ”๋ฅผ ์ฐพ๊ณ  ์‹ถ์€ ๋ถ„๋“ค์—๊ฒŒ ์œ ์šฉํ•œ ์ •๋ณด๊ฐ€ ๊ฐ€๋“ํ•ด์š”.

import ipywidgets as widgets
from IPython.display import display, clear_output
import datetime
from google.colab import drive

# Google Drive ๋งˆ์šดํŠธ
drive.mount('/content/drive')

# ์ €์žฅ ๊ฒฝ๋กœ ์„ค์ •
save_path = '/content/drive/MyDrive/alba_board.txt'

# ์ €์žฅ๋œ ๊ฒŒ์‹œ๊ธ€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
def load_posts():
    try:
        with open(save_path, 'r', encoding='utf-8') as f:
            posts = f.readlines()
        return posts
    except FileNotFoundError:
        return []

# ๊ฒŒ์‹œ๊ธ€ ์ €์žฅ ํ•จ์ˆ˜
def save_post(title, content):
    time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
    with open(save_path, 'a', encoding='utf-8') as f:
        f.write(f"{time} | {title} | {content}\n")

# ๊ธ€ ๋ชฉ๋ก ์ถœ๋ ฅ ํ•จ์ˆ˜
def show_posts(b):
    output.clear_output()
    posts = load_posts()
    if not posts:
        with output:
            print("\nโŒ ๋“ฑ๋ก๋œ ๊ธ€์ด ์—†์Šต๋‹ˆ๋‹ค.\n")
    else:
        with output:
            print("\n๐Ÿ“‹ ๋“ฑ๋ก๋œ ์•Œ๋ฐ” ๊ธ€ ๋ชฉ๋ก:\n")
            for p in posts:
                print(p)

# ๊ธ€ ๋“ฑ๋ก ํ•จ์ˆ˜
def add_post(b):
    title = title_text.value
    content = content_text.value
    save_post(title, content)
    output.clear_output()
    with output:
        print("\nโœ… ๊ธ€์ด ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.\n")
    title_text.value = ""
    content_text.value = ""

# ์ข…๋ฃŒ ํ•จ์ˆ˜
def exit_program(b):
    output.clear_output()
    with output:
        print("\n๐Ÿ‘‹ ํ”„๋กœ๊ทธ๋žจ์„ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.\n")

# UI ๊ตฌ์„ฑ
title_text = widgets.Text(placeholder="์ œ๋ชฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”")
content_text = widgets.Textarea(placeholder="๋‚ด์šฉ์„ ์ž…๋ ฅํ•˜์„ธ์š”", layout=widgets.Layout(width='400px', height='100px'))
add_button = widgets.Button(description="๊ธ€ ๋“ฑ๋ก")
view_button = widgets.Button(description="๊ธ€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ")
exit_button = widgets.Button(description="ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒ")
output = widgets.Output()

# ๋ฒ„ํŠผ๊ณผ ํ•จ์ˆ˜ ์—ฐ๊ฒฐ
add_button.on_click(add_post)
view_button.on_click(show_posts)
exit_button.on_click(exit_program)

# ์ธํ„ฐํŽ˜์ด์Šค ์ถœ๋ ฅ
display(title_text, content_text, add_button, view_button, exit_button, output)
๋‚จ
๋‚จ์Šนํ›ˆ
์•Œ๋ฐ” ํ›„๊ธฐ
โ€ข
์•„๋ฅด๋ฐ”์ดํŠธ ์ด๋ฆ„: ์•„์‹œ์•„๋‚˜์—์–ดํฌํŠธ ๋ถ€์‚ฐ์ง€๋ถ€ ์ˆ˜ํ•˜๋ฌผ ์ ์žฌ/ํ•˜๊ธฐ ํŒŒํŠธํƒ€์ด๋จธ
โ€ข
๊ทผ๋ฌด ์‹œ๊ฐ„: ์˜ค์ „ 6์‹œ 30๋ถ„-์˜ค์ „ 9์‹œ 30๋ถ„, ์ผ 3์‹œ๊ฐ„, ์ฃผ 4์ผ ๊ทผ๋ฌด
โ€ข
๊ทผ๋ฌด ์ˆ˜๋‹น: ์‹œ๊ธ‰ 15000์›(4๋Œ€๋ณดํ—˜ ๊ฐ€์ž…), ์‹๊ถŒ ์ œ๊ณต
โ€ข
ํ‰์ : 4.3
โ€ข
ํ‰๊ฐ€: ํ•œ๊ฒจ์šธ 1์›” ์ค‘์ˆœ~2์›”๋ง๊นŒ์ง€ ์•ฝ ํ•œ ๋‹ฌ ๋ฐ˜๊ฐ€๋Ÿ‰ ๊ทผ๋ฌดํ–ˆ์Œ. ๊ทผ๋ฌด์ง€๋Š” ๊น€ํ•ด๊ตญ์ œ๊ณตํ•ญ ๋‚ด.
๋…ธ๋™ ๊ฐ•๋„๊ฐ€ ์ข€ ์žˆ๋Š” ํŽธ. ๋‹ค๋งŒ ์ต์ˆ™ํ•ด์ง€๋ฉด ์ข€ ๋‚ซ๋‹ค. ๋…ธ๋™ ๊ฐ•๋„๊ฐ€ ๋นก์„ผ๋งŒํผ ์‹œ๊ธ‰๋„ ๋งŽ๋‹ค. ๊ทผ๋ฌด์‹œ๊ฐ„์ด 6์‹œ ๋ฐ˜์ธ๊ฒŒ ํž˜๋“ค๋‹ค. ์ง‘์ด ๊น€ํ•ด๋ผ์„œ ์ฒซ ์ฐจํƒ€๊ณ  ๊ฐ”์Œ. ๊ทผ๋ฌด ๋‚ด์šฉ์€ ๋น„ํ–‰๊ธฐ ํ™”๋ฌผ์นธ์—์„œ ์บ๋ฆฌ์–ด ๋„ฃ๊ณ  ๋นผ๋Š” ๊ฒƒ. ๋น„ํ–‰๊ธฐ๋ž‘ ๊ณตํ•ญ์„ ์ข‹์•„ํ•˜๋ฉด ํ•œ ๋ฒˆ์ฏค์€ ํ•ด๋ณด๊ธธ. ๋Œ€์‹  ์•ˆ์ข‹์•„ํ•˜๋ฉด ๋ณ„๋กœ์ž„,,, ๋‚˜๋Š” ๊ฐœ์ธ์ ์œผ๋กœ ์ •๋ง ์ข‹์•˜๋˜ ๊ฒฝํ—˜์ด์—ˆ์Œ!! ๋‹ค์‹œ ์˜ค๋ผ๋ฉด ๋˜ ๊ฐˆ ์ •๋„๋กœ
๐Ÿ‘
๊น€
๊น€๋‘ํ˜

์•Œ๋ฐ” ํ›„๊ธฐ/์ถ”์ฒœ ์˜ˆ์‹œ

์•Œ๋ฐ” ํ›„๊ธฐ/์ถ”์ฒœ

โ€ข
์•„๋ฅด๋ฐ”์ดํŠธ ์ด๋ฆ„
โ€ข
์•Œ๋ฐ” ์‹œ๊ฐ„
โ€ข
์•Œ๋ฐ” ์ˆ˜๋‹น
โ€ข
์•Œ๋ฐ” ํ‰์ (1~5)
โ€ข
์•Œ๋ฐ”์˜ ๊ฐœ์ธ์ ์ธ ํ‰๊ฐ€
๐Ÿ‘