"Python"의 두 판 사이의 차이

wwiki
이동: 둘러보기, 검색
(Dictionary)
(string)
24번째 줄: 24번째 줄:
 
=== trim===
 
=== trim===
 
https://www.w3schools.com/python/ref_string_strip.asp
 
https://www.w3schools.com/python/ref_string_strip.asp
 +
 +
=== length ===
 +
 +
=== substring ===
 +
문자열은 배열과 같으므로 다음과 같이 접근이 가능하다.
 +
 +
-는 negative index로 뒤에서 5번째에서 뒤에서 세번째까지의 문자열을 구할 수도 있다.<syntaxhighlight lang="python">
 +
string[2:5]
 +
 +
string[-5:-3]
 +
</syntaxhighlight>
 +
 
==built in functions==
 
==built in functions==
 
===len===
 
===len===
 
length
 
  
 
https://www.w3schools.com/python/ref_func_len.asp
 
https://www.w3schools.com/python/ref_func_len.asp

2019년 12월 8일 (일) 06:48 판

python2

pip 설치

$ sudo apt install python-pip

패키지 설치

$ python -m pip install 패키지명

python3

https://docs.python.org/ko/3/howto/index.html

pip3 설치

$ apt install python3-pip

패키지 설치

$ sudo pip3 install 패키지명

웹 크롤링

Selenium

string

split

https://www.w3schools.com/python/ref_string_split.asp

trim

https://www.w3schools.com/python/ref_string_strip.asp

length

substring

문자열은 배열과 같으므로 다음과 같이 접근이 가능하다.

-는 negative index로 뒤에서 5번째에서 뒤에서 세번째까지의 문자열을 구할 수도 있다.

string[2:5]

string[-5:-3]

built in functions

len

https://www.w3schools.com/python/ref_func_len.asp

Dictionary

https://www.w3schools.com/python/python_dictionaries.asp

Datetime

https://www.w3schools.com/python/python_datetime.asp

에러

UnicodeDecodeError: 'ascii' codec can't decode byte

import sys 이후에 다음 코드 추가

reload(sys)
sys.setdefaultencoding('utf-8')