반응형
반응형

https://streamlit.io/

 

streamlit

A faster way to build and share data apps

pypi.org

https://pypi.org/project/streamlit/

 

Streamlit • A faster way to build and share data apps

Streamlit is an open-source Python framework for machine learning and data science teams. Create interactive data apps in minutes.

streamlit.io

https://pyscript.com/

 

PyScript

 

pyscript.com

What is Streamlit?

Streamlit lets you transform Python scripts into interactive web apps in minutes, instead of weeks. Build dashboards, generate reports, or create chat apps. Once you’ve created an app, you can use our Community Cloud platform to deploy, manage, and share your app.

Why choose Streamlit?

  • Simple and Pythonic: Write beautiful, easy-to-read code.
  • Fast, interactive prototyping: Let others interact with your data and provide feedback quickly.
  • Live editing: See your app update instantly as you edit your script.
  • Open-source and free: Join a vibrant community and contribute to Streamlit's future.

Installation

Open a terminal and run:

$ pip install streamlit
$ streamlit hello

 

ctrl + C : 웹서버 shutdown 

 

.

반응형
반응형

lambda 매개변수 : 표현식

 

https://wikidocs.net/64

"""  lambda function 
A lambda function is a small anonymous function.
A lambda function can take any number of arguments, but can only have one expression.

lambda 매개변수 : 표현식
함수를 딱 한 줄만으로 만들게 해주는 훌륭한 녀석
"""

x = lambda a : a + 10
print(' lambda a : a + 10 => ', x(5))

x = lambda a, b : a * b
print(' lambda a, b : a * b => ', x(5, 6))

x = lambda a, b, c : a + b + c
print(' lambda a, b, c : a + b + c => ', x(5, 6, 2))
 
def myfunc(n):
  return lambda a : a * n

mydoubler = myfunc(2)

print(mydoubler(11))

def myfunc(n):
  return lambda a : a * n

mytripler = myfunc(3)

print(mytripler(11))

def myfunc(n):
  return lambda a : a * n

mydoubler = myfunc(2)
mytripler = myfunc(3)

print(mydoubler(11))
print(mytripler(11))

반응형
반응형

[python] pip install prettytable, 표 형태로 데이터를 보여준다. 

 

pip install prettytable

 

 

https://pypi.org/project/prettytable/

 

prettytable

A simple Python library for easily displaying tabular data in a visually appealing ASCII table format

pypi.org

시각적으로 매력적인 ASCII 테이블 형식으로 표 형식의 데이터를 쉽게 표시하기 위한 간단한 Python 라이브러리

A simple Python library for easily displaying tabular data in a visually appealing ASCII table format

 

from prettytable import PrettyTable

# Create a PrettyTable object
table = PrettyTable()

# Define the table's columns
table.field_names = ["Name", "Age", "City"]

# Add rows to the table
table.add_row(["Alice", 30, "New York"])
table.add_row(["Bob", 25, "Los Angeles"])
table.add_row(["Charlie", 35, "Chicago"])

# Print the table
print(table)

 

# HTML 형식으로 테이블 표시


# HTML 형식으로 테이블 표시
# PrettyTable은 HTML 형식으로 테이블을 인쇄합니다 <table>. ASCII 형식과 마찬가지로 실제로 문자열 표현을 얻을 수 있습니다 
# get_html_string(). . HTML 인쇄는 ASCII 인쇄 와 동일한 방식으로 fields, start, 및 인수를 지원합니다.

print('\n\n',table.get_html_string(attributes={"id":"my_table", "class":"red_table"}))

반응형
반응형

[python] 한글 자음 확인해서 치환하기 

 

""" 한글 자음인지 확인 
"""
# Define the list of Korean initial consonants (초성)
INITIAL_CONSONANTS = [
    'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 
    'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 
    'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ'
]

def is_korean_char(ch):
    """Check if the character is a Korean syllable."""
    return 0xAC00 <= ord(ch) <= 0xD7A3

def get_initial_consonant(ch):
    """Extract the initial consonant from a Korean syllable."""
    if not is_korean_char(ch):
        return None  # or you could return an empty string or raise an exception
    
    # Calculate the index for the initial consonant
    initial_index = (ord(ch) - 0xAC00) // (21 * 28)
    return INITIAL_CONSONANTS[initial_index]

# Example usage
sentence = "안녕하세요"
initials = [get_initial_consonant(ch) for ch in sentence if is_korean_char(ch)]
print(''.join(initials))  # Output: ㅇㄴㅎㅅㅇ
반응형
반응형

https://pypi.org/project/chardet/

 

Project description

Chardet: The Universal Character Encoding Detector

 
 
 
Detects
  • ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
  • Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese)
  • EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP (Japanese)
  • EUC-KR, ISO-2022-KR, Johab (Korean)
  • KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
  • ISO-8859-5, windows-1251 (Bulgarian)
  • ISO-8859-1, windows-1252, MacRoman (Western European languages)
  • ISO-8859-7, windows-1253 (Greek)
  • ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
  • TIS-620 (Thai)

Note

Our ISO-8859-2 and windows-1250 (Hungarian) probers have been temporarily disabled until we can retrain the models.

Requires Python 3.7+.

반응형
반응형

[python] 엑셀 읽고 쓰기 

 

https://pypi.org/project/openpyxl/

 

openpyxl

A Python library to read/write Excel 2010 xlsx/xlsm files

pypi.org

 

pip install openpyxl

 

반응형

+ Recent posts