본문 바로가기

개발일지/임시카테고리689

22.03.02 [파이썬 웹개발] 정규표현식 파이썬에 있어서 "정규 표현식"은 진짜 별 답답하고 외계어같은가. 싶으면서도 보면 볼 수록 유용할 것같은 직감이 빡빡 오는 그런 것이라서 소개하고자 한다. 일단, 이 정규표현식을 연습할 수 있는 사이트는 https://regexr.com/639t5 RegExr: Learn, Build, & Test RegEx RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp). regexr.com 여기이다. ================================================ import re # re 는 정규표현식 *, 이런 것들. # 1. re 모듈의 메서드 str = "love people aro.. 2022. 3. 2.
22.03.02 [파이썬 웹개발] class 마지막 파트 정말 class가 난해했다. unit_info={ "probe":{ "name": "프로브", "mineral" : 50, "gas" : 0, "hp" : 20, "shield" : 20, "demage" : 5 }, "zealot" : { "name" : "질럿", "mineral" : 100, "gas" : 0, "hp" : 100, "shield" : 60, "demage" : 16 }, "dragoon" : { "name" : "드라군", "mineral" : 125, "gas" : 50, "hp" : 100, "shield" : 80, "demage" : 20 } } # 유닛 클래스 class Unit: ''' 속성: 이름, 체력, 방어막, 공격력 ''' def __init__(self, nam.. 2022. 3. 2.
22.03.01 [파이썬 웹개발] class 다시! part1 class는 할 수록 익숙해지는 것 같다. 이해를 한다기 보다는 쇠뇌당해서 그게 맞게끔 생각하게끔 되는 느낌이랄까? 나름의 논리가 있고 그게 합리적이게 보이기도, 비합리적이게 보이기도 한다. # Unit 클래스 class Unit: ''' 속성: 이름, 체력, 방어막, 공격력 ''' # 생성자 (constructor) # 객체를 생성할 때 호출되는 메서드 def __init__(self,name, hp, shield, demage): self.name = name self.hp = hp self.shield = shield self.demage = demage print(f"[{self.name}](이)가 생성 되었습니다.") # 객체를 출력할 때 호출되는 메서드 def __str__(self): ret.. 2022. 3. 1.
22.03.01 [파이썬 웹개발] map, filter 함수 이용 # 1. map 함수 # - 사용 이유 # 기존 리스트를 수정해서 새로운 리스트를 만들 때 사용 # - 사용 방법 # map(함수, 순서가 있는 자료형) print(list(map(int,["3","4","5","6"]))) # - 예제 # 리스트 모든 요소의 공백 제거 items = [" 로지텍마우스 "," 앱솔 키보드 "] # 1) for 사용 # for i in range(len(items)): # items[i] = items[i].strip() # print(items) # 2) map 사용 # def strip_all(x): # return x.strip() # items=list(map(strip_all, items)) # print(items) # 3) 람다 함수 사용 items = lis.. 2022. 3. 1.