Python 6

프로그래머스 코딩 기초 트레이닝 Python Day16 ~ Day25

DAY16 문자열 대문자로 바꾸기def solution(myString): return myString.upper()테스트:print(solution("aBcDeFg"))# "ABCDEFG"print(solution("AAA"))# "AAA"설명:upper() 메서드는 문자열의 모든 알파벳을 대문자로 변환이미 대문자인 경우는 그대로 유지됨 소문자로 바꾸기def solution(myString): return myString.lower()테스트:print(solution("aBcDeFg"))# "abcdefg"print(solution("aaa"))# "aaa"설명:lower() 메서드는 문자열의 모든 알파벳을 소문자로 변환이미 소문자인 경우는 그대로 유지됨 배열에서 문자열 대소문자 변환하기def ..

[Python/AI] Hugging Face와 Streamlit으로 구현하는 감정 분석 웹 애플리케이션 -1편 코드

개요이번 포스팅에서는 Hugging Face의 Transformers 라이브러리와 Streamlit을 활용하여 감정 분석 웹 애플리케이션을 구현하는 방법을 다룹니다. 프로덕션 레벨의 코드 구조와 실제 구현 방법에 중점을 두어 설명하겠습니다.기술 스택Python 3.8+Hugging Face TransformersStreamlitPyTorchVS Code프로젝트 구조sentiment_analysis/├── .vscode/ # VSCode 설정│ └── settings.json├── src/ # 소스 코드│ ├── __init__.py│ ├── analyzer.py # 감정 분석 핵심 로직│ ├── utils.py ..

LLM(Open AI) 2024.11.16

Chatgpt 이용한 프로그램 짜기 - 파이썬 영어 문서 한글 번역

✔ GPT 입력 : 파이썬으로 "C:\Users\user\OneDrive\바탕 화면\english.txt" 파일에서 영어를 한국어로 번역해서 "C:\Users\user\OneDrive\바탕 화면\korea.txt" 파일에 저장하는 코드를 작성해줘 ✔ english.txt 파일 ✔ 코드 from googletrans import Translator def translate_text(input_file, output_file, source_lang="en", target_lang="ko"): # Read the input file containing English text with open(input_file, "r", encoding="utf-8") as file: english_text = file.re..

Chatgpt 2023.07.29

Chatgpt 이용한 프로그램 짜기 2 - 파이썬(내부 ,외부 IP 찾기)

✔ 내부IP 찾기 gpt입력 : 파이썬으로 컴퓨터 내부 IP를 확인하는 코드를 작성해줘 import socket def get_internal_ip(): # 호스트 이름 가져오기 hostname = socket.gethostname() # 호스트 이름을 IP 주소로 변환하기 internal_ip = socket.gethostbyname(hostname) return internal_ip internal_ip = get_internal_ip() print("내부 IP 주소:", internal_ip) ✔ 외부IP 찾기 gpt입력 : 파이썬으로 컴퓨터 외부 IP를 확인하는 코드를 작성해줘 import requests def get_external_ip(): url = 'https://api.ipify.org..

Chatgpt 2023.07.16

백준 python(1000, 10869, 18108, 1330, 2739, 10950, 8393)

✔ 백준 Python 아직 Python이 초보긴 하지만 책만 보고 공부하기 너무 심심하고 부족해서 따로 문제룰 풀고 싶어 복습용으로 풀기 시작하였습니다. # 1000번 A + B A,B = input().split() # input은 문자형으로 받는다, split()은 () 공백으로 나눈다 print(int(A)+int(B)) # input은 문자형안데 수를 더할려면 정수형 int()를 사용하여 정수로 변경 # 10869번 사칙연산 A,B = input().split() print(int(A)+int(B)) print(int(A)-int(B)) print(int(A)*int(B)) print(int(A)//int(B))# / 나누기 // 몫 print(int(A)%int(B))# % 나머지 # 18108..