본문 바로가기
반응형

분류 전체보기136

[Python] csv 모듈을 이용하여 파일 읽고, 쓰기 | LIM 파이썬으로 CSV 파일 읽기(mode='r') with 문 사용 - with 문을 사용해서 읽고 쓸 경우 파일을 닫을 필요가 없습니다. import csv with open('test.csv', 'r') as f: reader = csv.reader(f) for line in reader: print(line) ['Name', ' Height'] ['Robin', ' 170'] ['Rudy', ' 150'] ['Mike', ' 190'] ['Hailey', ' 160'] with 문 사용하지 않는 경우 import csv f = open('test.csv', 'r') reader = csv.reader(f) for line in reader: print(line) f.close() 파이썬으로 CSV 파일.. 2023. 5. 10.
[Docker] 컨테이너에 저장된 데이터 유지(Volume Mount) | LIM Docker 컨테이너 내부에 쓰인 데이터는 기본적으로 컨테이너가 삭제될 때 함께 사라진다. 따라서 Docker에서 수집한 데이터를 영속적으로 저장하기 위해서는 다른 방법이 필요하다. Docker 컨테이너의 생명 주기와 상관없이 데이터를 저장할 수 있도록 Docker는 두 가지 옵션을 제공한다. 첫 번째는 bind mount, 두 번째는 volume이다. 1. bind mount(바인드 마운트) 바인드 마운트는 호스트 시스템의 경로(파일 또는 폴더)가 컨테이너에 마운트 되는 형태이다. 경로가 존재하지 않으면 생성하여 마운트하고 호스트 시스템의 경로에 모두 접근할 수 있다. 사실 처음에 이 말만 들었을 때는 잘 이해가 안 됐는데 로컬에서 테스트해보니 이해가 되었다. 간단하게 코드를 통해 살펴보도록 하자. .. 2023. 5. 10.
[Grafana] 브라우저 시간 받아오기 (Get Browser Time)| LIM 그라파나에서 구글 빅쿼리와 연동 시 대시보드 상단의 시간 받아오는 방법 그라파나에서 브라우저 상에 보이는 From, To 를 받아오는 방법 ✅ MySQL 과 연동 시 select $__timeFrom() select $__timeTo() python 으로 timestamp를 datetime 으로 변경하기 import datetime ut = 1682974002000 dt = datetime.datetime.fromtimestamp(ut/1000).strftime('%Y-%m-%dT%T') >> '2023-05-02T05:46:42' ✅ 빅쿼리와 연동 시 select $__from select $__to date 로 받아오기 select '${__from:date:YYYY-MM-DD}' select '$.. 2023. 5. 8.
[LeetCode] 3. Longest Substring Without Repeating Characters | LIM 문제 https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ 포인터를 이동할 때 i는 기존에 있던 칸에서 한칸 오른쪽으로 이동, j의 경우 i 다음칸으로 이동 그림으로 보면 이러하다. 코드 from collections import defaultdict class Solution: def lengthOfLongestSubstring(self, s: str) -> int: sub = defaultdict(int) i, j = 0, 1 max_len = 0 if not len(s): return 0 sub[s[0]] = 1 while j < len(s): if not sub[s[j]]: sub[s[j]].. 2023. 5. 7.
[LeetCode] 167. Two Sum II - Input Array Is Sorted | LIM 문제 https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ Two Sum II - Input Array Is Sorted - LeetCode Can you solve this real interview question? Two Sum II - Input Array Is Sorted - Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two n leetcode.com Given a 1-index.. 2023. 5. 4.
[LeetCode] 350. Intersection of Two Arrays II | LIM 문제 https://leetcode.com/problems/intersection-of-two-arrays-ii/ Intersection of Two Arrays II - LeetCode Can you solve this real interview question? Intersection of Two Arrays II - Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return leetcode.com Given two integer arrays.. 2023. 5. 3.
반응형