본문 바로가기
반응형

Python14

vscode python 에러 - 용어가 cmdlet, 함수, 스크립트 파일 또는 실행할 수 있는 프로그램 이름으로 인식되지 않습니다 PS E:\Backup\Study\BigData\Python\100days> https://code.visualstudio.com/docs/editor/editingevolved e:; cd 'e:\Backup\Study\BigData\Python\100days'; & 'C:\Users\Smith\AppData\Local\Microsoft\WindowsApps\python3.8.exe' 'c:\Users\Smith\.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '8350' '--' 'E:\Backup\Study\BigData\Python\100days\16da.. 2023. 4. 15.
python batch runner 대략적 한글로 https://codingmoonkwa.tistory.com/286 [Python] python-batch-runner, 파이썬 배치 관리 파이썬 배치 스크립트 작성 후, 여러 파일을 순차적으로 호출하는 일이 필요해졌다. 처음에는 crontab을 이용해 하나씩 호출하려 했으나 관리가 될까 의문이 들었고, 여러 서치 끝에 python-batch-runne codingmoonkwa.tistory.com 공식가이드 https://python-batch-runner.readthedocs.io/en/latest/ Home - python-batch-runner Documentation Overview The purpose of this project ("PyRunner" for short) is t.. 2022. 8. 12.
배열 - 두수의 합 https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com from typing import List class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: nums_map = {} # 키와 값을 바꿔서 딕셔너리로 저장 for i, num in enumerate(nums): nums_map[num] = i .. 2021. 9. 9.
그룹 애너그램 49번 문제 strs = ["eat","tea","tan","ate","nat","bat"] import collections from typing import List class Solution: def groupAnagrams(self, strs: List[str]) -> List[List[str]]: anagrams = collections.defaultdict(list) for word in strs: # 정렬하여 딕셔너리에 추가 anagrams[''.join(sorted(word))].append(word) return list(anagrams.values()) a = Solution() a.groupAnagrams(strs) collections.defaultdict https://dongdo.. 2021. 8. 31.
json 사용법 (Python) https://docs.python.org/ko/3/library/json.html json — JSON 인코더와 디코더 — Python 3.9.6 문서 json — JSON 인코더와 디코더 소스 코드: Lib/json/__init__.py RFC 7159(RFC 4627을 대체합니다)와 ECMA-404로 규정되는 JSON (JavaScript Object Notation)은 JavaScript 객체 리터럴 문법에서 영감을 얻은 경량 데이터 교 docs.python.org 2021. 8. 2.
GitHub와 VSCode 연동하기 목차 2021.07.29 처음으로 깃을 써본다. 설치해야할것들 우선 깃허브 계정과 VScode 설치가 필요하다. 깃허브는 직접가서 가입하시면되고 https://github.com/ vscode는 여기서 다운받아 설치 https://code.visualstudio.com/ cmd에서 git을 쳐서 아무 반응없으면 설치가 안된것이다. 그럼 설치를 해볼까? 여기서 자신의 환경에 맞춰서 다운받아 설치하자 https://git-scm.com/download/win [ Git - Downloading Package Downloading Git Now What? Now that you have downloaded Git, it's time to start using it. git-scm.com ](https://gi.. 2021. 7. 29.
언더스코어(underscore) https://www.datacamp.com/community/tutorials/role-underscore-python 2021. 7. 25.
main 함수 import sys def main(): print('hi') if __name__=='__main__': main() else: print('hello world') 2021. 6. 22.
Python으로 파일 치환 및 업로드 치환 1 2 3 4 5 6 7 8 9 10 11 12 13 def replaceInFile(file_path, oldstr, newstr): fr = open(file_path, 'r') lines = fr.readlines() fr.close() fw = open(file_path, 'w') for line in lines: fw.write(line.replace(oldstr, newstr)) fw.close() # 호출: 123.txt 파일에서 comma(,) 없애기 replaceInFile("C:\\docker\\example\\123.txt", "nbc", "abc") cs 업로드 requests 모듈을 설치를 따로 해줘야 하고 requests.post ( 주소 , 보낼형식)이런식이라고 생각하면된.. 2021. 5. 18.
'_' 언더스코어 1. 특정이름 2. 무시하고 싶을때 for _ in range(10) print('hello world') 이런식 3. 이전에 사용햇던거 다시사용 >>a = 10 >>_ 10 2021. 5. 12.
기억해야할 표현 - 파이썬알고리즘 인터뷰 공부 letters.sort(key=lambda x: (x.split()[1:], x.split()[0])) letters를 x.split[1:]순으로 정렬하고 일치시 [0]로 정렬 class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: words = [word for word in re.sub(r'[^\w]', ' ', paragraph) .lower().split() if word not in banned] counts = collections.Counter(words) # 가장 흔하게 등장하는 단어의 첫 번째 인덱스 리턴 return counts.most_common(1)[0][0] 1 2 3 4 5 6 7 8.. 2021. 5. 6.
Algorithm 동적계획법(DP) 입력 크기가 작은 부분 문제들을 해결한 후, 해당 부분 문제의 해를 활용해서, 보다 큰 크기의 부분 문제를 해결, 최종적으로 전체 문제를 해결하는 알고리즘 def fibo_dp(num): cache = [ 0 for index in range(num + 1)] cache[0] = 0 cache[1] = 1 for index in range(2, num + 1): cache[index] = cache[index - 1] + cache[index - 2] return cache[num] 퀵정렬 기준점(pivot 이라고 부름)을 정해서, 기준점보다 작은 데이터는 왼쪽(left), 큰 데이터는 오른쪽(right) 으로 모으는 함수를 작성함 def qsort(data): if len(data) .. 2021. 4. 28.
반응형