목록[Python] (62)
코드민수
문제 설명 영어 알파벳으로 이루어진 문자열 str이 주어집니다. 각 알파벳을 대문자는 소문자로 소문자는 대문자로 변환해서 출력하는 코드를 작성해 보세요. 제한사항 1 ≤ str의 길이 ≤ 20 str은 알파벳으로 이루어진 문자열입니다. 입출력 예 입력 #1 aBcDeFg 출력 #1 AbCdEfG 정답 str = input() print(str.swapcase()) 출처: https://school.programmers.co.kr/learn/courses/30/lessons/181949
문제 설명 문자열 str과 정수 n이 주어집니다. str이 n 번 반복된 문자열을 만들어 출력하는 코드를 작성해 보세요. 제한사항 1 ≤ str의 길이 ≤ 10 1 ≤ n ≤ 10 입출력 예 입력 #1 string 5 출력 #1 stringstringstringstringstring 정답 a, b = input().strip().split(' ') b = int(b) print(a*b) 출처: https://school.programmers.co.kr/learn/courses/30/lessons/181950
문제 설명 정수 a와 b가 주어집니다. 입출력 예와 같은 형식으로 출력하는 코드를 작성해 보세요. 제한사항 -100,000 ≤ a, b ≤ 100,000 입출력 예 입력 #1 4 5 출력 #1 a = 4 b = 5 정답 a, b = map(int, input().strip().split(' ')) print('a =', a) print('b =', b) 출처: https://school.programmers.co.kr/learn/courses/30/lessons/181951
문제 설명 문자열 str이 주어질 때, str을 출력하는 코드를 작성해 보세요. 제한사항 1 ≤ str의 길이 ≤ 1,000,000 str에는 공백이 없으며, 첫째 줄에 한 줄로만 주어집니다. 입출력 예 입력 #1 HelloWorld! 출력 #1 HelloWorld! 정답 str = input() print(str) 출처: https://school.programmers.co.kr/learn/courses/30/lessons/181952
경로 A에서 경로 B로 n 개의 파일을 복사하는 파이썬 코드입니다 import os import random import shutil from tqdm import tqdm def copy_random_files(source_path, destination_path, num_files): files = os.listdir(source_path) # 파일 목록에서 랜덤하게 num_files 개의 파일 선택 random_files = random.sample(files, num_files) # 파일을 경로 B로 복사 for file in tqdm(random_files): source_file = os.path.join(source_path, file) destination_file = os.path.joi..

해당 폴더에 있는 V2 포맷의 events.out.tfevents 파일을 tensorboard를 사용해서 열어보겠습니다. 1. tensorflow와 tensorboard가 설치되어 있는 가상환경 실행 2. 명령문 실행 tensorboard --logdir= V2 등 파일이 아닌 해당 파일이 있는 경로를 입력하셔야 합니다. 3. http://localhost:6006 접속

from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt plt.figure(figsize=(10, 10)) map = Basemap(projection='merc', lat_0=37.35, lon_0=126.58, resolution='h', urcrnrlat=44, llcrnrlat=32, llcrnrlon=121.5, urcrnrlon=132.5) map.drawcoastlines() map.drawcountries() map.drawmapboundary() plt.savefig('map.png', bbox_inches='tight') plt.savefig() 에 bbox_inches='tight'를 추가하면 됩니다.
from glob import glob import numpy as np from osgeo import gdal glob_image_dir = 'D:/temp/image/*.tif' # 이미지 확장자 수정 image_filename_list = glob(glob_image_dir) def load_images(): global image_filename_list image_list = [] for idx, image_filename in enumerate(image_filename_list): image_ds = gdal.Open(image_filename) image = image_ds.ReadAsArray().astype(np.int16) # 0~255 이미지는 int8로 충분 image_list...