전체 글

자바, 파이썬 등 개발 관련 정보와 블록체인, OpenAI 등 기술에 관한 정보를 남기는 블로그입니다.
Development

[Python] 랜덤 비밀번호 생성하기

Python ramdom 라이브러리를 사용한 랜덤 비밀번호 생성 예제를 소개한다. 샘플 코드 import random def generate_random_password(length): characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*" password = ''.join(random.choice(characters) for _ in range(length)) return password # Example usage password_length = 10 random_password = generate_random_password(password_length) print("Random Password:", ..

Development

[Python] datetime으로 현재 날짜/시간 받아오기

datetime 라이브러리를 사용해 현재 날짜와 시간을 받아오는 방법을 소개한다. datetime 라이브러리 날짜와 시간을 조작하는 다양한 기능을 제공하는 라이브러리. 자세한 설명은 아래 링크에서 확인. https://docs.python.org/ko/3/library/datetime.html datetime — Basic date and time types Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient att..

Development

[Python] csv 파일 읽기

개발을 하다보면 CSV 파일에 있는 데이터를 읽어서 사용하는 경우가 있다. 파이썬으로는 역시나 간단하게 구현이 가능하다. 우선 간단한 샘플 데이터 준비 hello,my,name,is,Lee this,is,the,example,code 파이썬으로 구현한 샘플 코드는 아래와 같다. import csv def read_csv(file_path): data = [] with open(file_path, 'r') as file: reader = csv.reader(file) for row in reader: data.append(row) return data # Example usage csv_file = "./file.csv" csv_data = read_csv(csv_file) for row in csv_da..

Development

jsontest.com - json 응답을 주는 테스트 API 사이트

API를 호출하는 기능을 개발하다보면 응답을 제대로 처리하기 위해 테스트 API가 필요한 경우가 있다. 특히 json 형태의 응답을 받게되는 경우가 많은데 테스트를 위한 API를 제공하는 사이트를 소개한다. jsontest.com http://www.jsontest.com/ JSON Test by jsontest JSONTest.com is a testing platform for services utilizing JavaScript Object Notation (JSON). To use, make a request to servicename.jsontest.com, where servicename is the name of a service listed below. We also support a nu..

Development

[Python] 디렉토리 파일 목록 받아오기

Python으로 디렉토리 내부에 있는 파일 목록을 받아오는 기능을 개발해 보았다. import os def list_files(directory): file_list = [] for root, dirs, files in os.walk(directory): for file in files: file_path = os.path.join(root, file) file_list.append(file_path) return file_list # Example usage # directory_path = "/path/to/directory" directory_path = "C:\Python34" # windows files = list_files(directory_path) for file in files: pri..

Development

[Python] requests 사용해 API 호출

파이썬에서 API 호출 시 많이 사용하는 requests 패키지를 사용해 보았다. requests 패키지를 사용하면 간단한 코드만으로도 API 호출이 가능하다. 패키지 설치 pip install requests 기본 사용법 imports requests response = requests.get(url) response = requests.post(url) response = requests.delete(url, data={'key':'value'}) response = requests.head(url) response = requests.options(url) Json 응답 처리 (GET) API 응답이 json 형태일때 처리하는 샘플 코드를 개발해 보았다. json 응답을 테스트해볼 수 있는 사이트가..

삿뿐삿뿐
정보 남기기