반응형

[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"}))

반응형
반응형

[텃밭]  2024년 텃밭 시작

반응형
반응형

떠밀려 간다
떠밀고 간다

 

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

내 인생의 전성기  (0) 2024.03.27
나이 든 사람의 처신  (0) 2024.03.26
요행을 바라는 사람들  (0) 2024.03.25
눈깔사탕과 다이아몬드를 바꾼 사람들  (0) 2024.03.22
몸의 명상  (0) 2024.03.21
반응형

요행을 바라는 사람들은
대개 허황된 마음에 들떠 있는 사람들이다.
하늘에서 돈벼락이나 내렸으면, 어디 뭐 좋은 것
없을까? 하고 망상에 잠기기도 한다. 자신이 원하는
것을 얻기 위해서는 땀을 흘리고, 열정을 바쳐야
기필코 얻어지는 법이다. 노력을 통해 이룬
행복은 쉽사리 사라지지 않는다.


- 신현식의 《배려》 중에서 -


* 꿈은
요행으로 이루어지지 않습니다.
요행을 바라는 것은 그야말로 망상입니다.
설사 요행으로 이루었다 해도 오래 가지 못합니다.
오히려 재앙이 되기 쉽습니다. 꿈은 땀과 열정을
요구합니다. 실패와 좌절의 쓴 잔을 견디어내야
합니다. 쓰러져도 툴툴 털고 다시 일어나는
불굴의 용기가 필요합니다. 그러다가
때가 되면 꿈은 이루어집니다.

반응형

'생활의 발견 > 아침편지' 카테고리의 다른 글

나이 든 사람의 처신  (0) 2024.03.26
차이  (0) 2024.03.25
눈깔사탕과 다이아몬드를 바꾼 사람들  (0) 2024.03.22
몸의 명상  (0) 2024.03.21
남들의 잘못 때문에  (0) 2024.03.20
반응형

전역 NaN 속성은 Not-A-Number(숫자가 아님)를 나타냅니다.

 

function sanitise(x) {
  if (isNaN(x)) {
    return NaN;
  }
  return x;
}

console.log(sanitise('1'));
// Expected output: "1"

console.log(sanitise('NotANumber'));
// Expected output: NaN

 

반응형
반응형

[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+.

반응형
반응형

알베르트 아인슈타인은 호기심과 질문을 성장에 있어서 가장 중요한 요소라고 강조했습니다. 그러면서 이런 명언을 남겼습니다.

 

  • 내 인생을 결정짓는 문제가 주어진다면, 나는 55분을 올바른 질문을 찾는데 사용하고, 5분을 정답을 찾는데 쓸 것이다.
  • “If I had an hour to solve a problem and my life depended on the solution, I would spend the first 55 minutes determining the proper question to ask for once I know the proper question, I could solve the problem in less than five minutes.”
반응형

+ Recent posts