pip install -r requirements.txt
[카테고리:] python
setting virtualenv setting python version
# make virtual environment setting python version pyenv virtualenv [python-version] [virtual_env_name] #make virtual environment using current python version pyenv virtualenv [virtual_env_name] # use virtual environment pyenv shell [virtual_env_name] # list virtual environments pyenv virtualenvs # pyenv activate [virtual_env_name] pyenv deactivate # pyenv uninstall [virtual_env_name]
uninstall pip library
pip3 uninstall virtualenv
change python version using pyenv
pyenv versions //check installed versions
python –version //check current python version
pyenv global <pyenv version> //or pyenv shell <pyenv version>
python –version
Server: print(X) -> logging(O)
On server, logging is better than print because of functionality, convenience, and maintenance
setting logger level to INFO (default: WARN)
logging.getLogger().setLevel(logging.INFO)
https://docs.python.org/3/howto/logging.html#logging-basic-tutorial
open file mode ‘a’ -> reader doesn’t work
open file mode ‘a’ -> reader doesn’t work
When you do nothing when error occurs
except exception:
pass
sample code;
Wait until ‘th’ element contains ‘제조’in text for 10 seconds
And then download page source.
try: element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, "//th[contains(text(), '제조')]"))) except TimeoutException: pass finally: pageSource = driver.page_source bsObj = BeautifulSoup(pageSource, "html.parser")
zip()
If you needed to combine two lists, you could use zip()
:
for shout_head, shout_foot in zip(shout_heads, shout_feet):
python 2-> 3 urlopen
html = urlopen("http://en.wikipedia.org/wiki/Python_(programming_language)", cafile=certifi.where()) cafile parameter를 붙여야 한다
semicolon
python에서 semicolon은 생략 가능하나
같은 줄에 두 라인을 넣기 위해서는 중간에 넣을 수도 있다