import [module] as [nick_name]


https://amir.rachum.com/blog/2012/08/25/you-cant-handle-the-truth/
if x and if x is not None are not the same!
None means no value
an empty list means zero values
if문 실행때 x의 __bool__() 또는 bool([])이 실행되어 true/false를 리턴한다.





이스케이프 문자

선택부분만 실행
alt + shift + E

정규표현식 sub 함수

three single or double quotes

unicode string

from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys import time Options를 이용하여 webdriver을 어떻게 이용할지 설정 headless, incognito 설정가능 options = Options() options.headless = False options.add_argument('incognito') # chrome headless driver = webdriver.Chrome(chrome_options=options) # chrome # driver = webdriver.Chrome() driver.get("https://www.google.com/ncr") assert "Google" in driver.title search_box = driver.find_element_by_name('q') search_box.clear() search_box.send_keys('파이썬공부') search_box.send_keys(Keys.ESCAPE) time.sleep(0.1) search_box = driver.find_element_by_name('btnK').click() # search_box.submit() search_results = driver.find_elements_by_css_selector('div.r') hrefs = [] for i in search_results: link = i.find_element_by_tag_name('a') hrefs.append(link.get_attribute('href')) for i in hrefs: driver.execute_script('window.open("' + i + '");') driver.save_screenshot(r'C:\Users\Administrator\Desktop\파이썬\screen.png')







https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do <설명> https://www.pythonlikeyoumeanit.com/Module2_EssentialsOfPython/Generators_and_Comprehensions.html 먼저 아래 4가지의 뜻을 정확히 이해해야된다. iterator : iteration상태로 순서대로 저장되어 있는것을 next명령에 따라 다 소진될때 까지 하나씩 yield하는 object generator : 메모리에 저장하지않고 많은 아이템을 수열 형태로 만들어내는 object (iterator의 한 형태) range()는 메모리에 저장되지 않고 사용후 사라지지만, list는 메모리에 저장되어 재사용 가능하다. comprehension expression, 즉 (<expression> for <var> in <iterable> [if <condition>]) 이런 형태로 generator를 만들수 있다. 이렇게 […]

2. 사용자 정의
3. If문 사용법 (return을 잊지말자.)
4. For문 사용법 (for 변수 in 영역)
5. 숫자표기법 format( ,”.4f”)