본문 바로가기
반응형

python71

[Python] [Streamlit 사용법] 3. button Streamlit Button 기본적인 사용법 import streamlit as st st.title("Streamlit Test") input_user_name = st.text_input(label="User Name", value="default value") if st.button("Confirm"): con = st.container() con.caption("Result") con.write(f"Hello~ {str(input_user_name)}") st.button() 은 True, False 를 리턴합니다. btn_clicked = st.button("Confirm") st.write(btn_clicked) 클릭하기 전(페이지 로딩)에는 False 를 찍고, 버튼을 클릭하면 True 를.. 2022. 2. 22.
[Python] matplotlib.pyplot 을 이용해서 line chart 만들기 LINE CHART import matplotlib.pyplot as plt plt.figure(figsize=(10, 5)) lang_list = ['2018', '2019', '2020', '2021', '2022'] plt.plot(lang_list, [10, 12, 15, 16, 20], marker='o') plt.plot(lang_list, [14, 16, 15, 18, 17], marker='o') plt.plot(lang_list, [20, 18, 15, 14, 12], marker='o') plt.legend(['Python', 'Java', 'Obj-C']) plt.grid(True) plt.show() plt.grid(False) 이면 Title, x, y Label plt.xlabe.. 2022. 2. 20.
[Python] matplotlib.pyplot 을 이용해서 pie chart 이미지로 만들기 matplotlib.pyplot pie chart 기본 생성 import matplotlib.pyplot as plt labels = ['Python', 'C#', 'Java', 'C/C++', 'Swift'] points = [30, 20, 30, 10, 10] plt.title('Langeuage usages') plt.pie(points, labels=labels, autopct='%.1f%%', counterclock=False, startangle=90) plt.show() startangle : 차트의 시작. 위 예에서는 90도 방향에서 시작하도록 했습니다. counterclock : False 일 경우 시계 방향으로 표시 색상 변경 colors 에 색상 list 를 넘겨주면 됩니다. labe.. 2022. 2. 20.
[Python] [Streamlit 사용법] 2. input_text Streamlit input_text html tag 의 ,.< ) 코드를 이렇게 하고, input 에 메시지를 입력하고, input 에서 focus out 하면 input 아래에 input 의 값이 text 로 써집니다. 입력된 텍스트를 가져오는 방법 2 key 옵션과 session_state 사용하기 session_state 로 이렇게 사용할 수 있습니다. 아주 유용합니다. 옵션 input = st.text_input(label="Message", value="기본값", max_chars=10, help='input message < 10') autocomplete 옵션 전 이미 존재하는 텍스트들을 미리 넣어두고 텍스트를 입력하면 보여주는.. 그런것인줄 알았는데. 단순히 브라우저에서 지원하는 자동입력.. 2022. 2. 17.
[Python] [Streamlit 사용법] 1. 설치 및 hello world~ Streamlit Streamlit 은 위 사진과 같이, python 으로 브라우저에 UI 를 쉽게 만들 수 있는 라이브러리 입니다. 공식 사이트 : https://streamlit.io/ 비슷한 라이브러리로 gradio 같은게 있습니다. 1. 설치 pip install streamlit 또는 requirements.txt 에 아래와 같이 입력 (최신 버전은 pypi 확인) streamlit==1.5.1 2. Test Code : helllo world test.py 에 아래와 같이 입력합니다. import streamlit as st st.title("Streamlit Test") st.write("hello world") st.write(""" # MarkDown > comment - one - tw.. 2022. 2. 17.
[Python] matplotlib.pyplot 을 이용해서 bar(막대) chart 만들기 matplotlib.pyplot bar chart 요런거 간단하게 만들어 보겠습니다. 라이브러리 설치 pip install matplotlib 또는 requirements.txt 에 matplotlib==3.5.1 최신 release 확인하기 import import numpy as np import matplotlib.pyplot as plt 데이터 만들기 height = [85, 95, 91, 78] bars = ('hello','bryan','tom','cat') y_pos = np.arange(len(bars)) height(y축) 는 시험성적이고, x 축은 학생이름으로 보겠습니다. bar 생성 plt.bar(y_pos, height) X축 이름 생성 plt.xticks(y_pos, bars) p.. 2022. 2. 16.
[Python] 빠른 이미지 다운로드 라이브러리 : urllib3 The fastest library for downloading image 특징 Thread safety. Connection pooling. Client-side SSL/TLS verification. File uploads with multipart encoding. Helpers for retrying requests and dealing with HTTP redirects. Support for gzip, deflate, and brotli encoding. Proxy support for HTTP and SOCKS. 100% test coverage. 설치 python -m pip install urllib3 예제1 import urllib3 http = urllib3.PoolManager() .. 2021. 10. 26.
[Python] pip 전역으로 설치하기. interpreter 골라서 pip 설치 Python pip interpreter global 파이썬 개발하다보면 전역으로 설치된 python 이 있을거고, (버전별로도 있을 수 있고) 가상환경으로 만든 python interpreter가 있을 겁니다. 가상환경이라면 venv 를 activate 해서 pip 명령어를 날려서 package 를 install 하면 되는데요. 전역(global) python 에 package 설치할 때, 원하는 파이썬 버전에 설치하려고 할때, 제 개발환경을 예를 들면 Interpreter 를 Python 3.7 로 사용하고 있죠. 콘솔창에서 pip install psutil 을 날려도 설치될 수도 있고 안될수도 있습니다. 이유는 전역 PATH에 다른 python interpreter 경로가 있을 수 있으니까요. 그래.. 2021. 7. 15.
[Python] flip : 이미지 반전 옵션 Image flip OpenCV cv2.flip(img, -1) : 좌우, 상하 반전 cv2.flip(img, 0) : 상하 반전 cv2.flip(img, 1) : 좌우 반전 Numpy np.flip(narray) : 좌우, 상하 반전 np.flipud(narray) : 상하 반전 np.fliplr(narray) : 좌우 반전 2021. 7. 12.
WSGI.. 누구냐 넌 WSGI Web Server Gateway Interface 발음 : 위스키 간단 호출 규칙 에 대한 웹 서버 로 전달 요청에 웹 애플리케이션 또는 프레임 워크 작성 파이썬 프로그래밍 언어 2003 년에 Python 웹 프레임 워크 는 일반적으로 CGI , FastCGI , mod_python 또는 특정 웹 서버 의 다른 사용자 정의 API 에 대해서만 작성되었습니다 WSGI에는 두 가지 측면이 있습니다. 서버 / 게이트웨이 측. 이것은 종종 Apache 또는 Nginx 와 같은 전체 웹 서버 소프트웨어를 실행 하거나 flup 와 같은 웹 서버와 통신 할 수있는 경량 애플리케이션 서버입니다 . 애플리케이션 / 프레임 워크 측면. 이것은 Python 프로그램 또는 프레임 워크에서 제공하는 Python 호출.. 2021. 6. 23.
728x90
반응형