๐ ๋ฆฌ์คํธ count() ๊ธฐ์ตํ๊ธฐ
temp = [1, 1, 2, 3, 4, 5] temp.count(1) # 2 temp.count(2) # 1
๐ replace() ํจ์
- ์ฌ๋ฌ ๋ฌธ์๋ฅผ ํ๋ฒ์ ๋ฐ๊พธ๊ณ ์ถ์๋ ํด๋น ๋ฌธ์๋ฅผ iterableํ ์ํจ ํ ๋ฐ๋ณต๋ฌธ ๋๋ ค์ ๋ฐ๋ณตํ๊ธฐ
- regex๋ฅผ ์ฌ์ฉํด๋ ๋๋ ์ฝ๋ฉํ ์คํธ ์ regex ์ฌ์ฉ ๋ฌธ์ ๊ฐ ๋์ฌ๋ฆฌ ๋ง๋ฌดํ๋ ๋ฐฐ์
temp = 'aaeeff' temp.replace('a', 'e') # 'eeeeff' temp.replace('a', 'e', 1) # 'eaeeff' temp_re = ['a', 'e', 'f'] for re in temp_re: temp = temp.replace(re, 'b') # 'bbbbbb'
๐ extends & include
- {% include 'test.html' %} ์ ์ฌ์ฉํ๊ฒ ๋๋ฉด test.html ํ์ผ์ ๊ฐ์ ธ์์ ์ํ๋ ์์น์ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
- {% extends 'test.html' %} ์ ์ฌ์ฉํ๊ฒ ๋๋ฉด test.html ํ์ผ์ ๋ค ๊ฐ์ ธ์ค๊ณ , test.html ์ ๋ธ๋ก ๋ด์ฉ๋ง ๋ฐ๊ฟ ์ ์๊ฒ ๋ง๋ค ์ ์๋ค.
ํ์ฌ ์ฌ์ฉ์ค์ธ ํ์ผ์ ๋๊ฐ์ ๋ธ๋ก์ ๋ง๋ค์ด ์ค ํ ๊ทธ ๋ธ๋ก ์ ๋ด์ฉ๋ง ์์ ์ ํ๊ฒ๋๋ฉด ๋ณ๊ฒฝ ๊ฐ๋ฅํ๋ค.
{% block '๋ธ๋ก๋ช ' %}
{% endblock %}
๐ ํ๋ก์ ํธ๋ฅผ ํ๋๋ผ ์ ์ ์ด ์์ด ๊ฐ๋จํ ๋ฌธ์ ๋ค๋ง ํ๊ณ ์๋ค.
๊ทธ๋๋ ์ฌ๋ฌ ๋ฌธ์ ๋ฅผ ํ๊ณ ์์ง๋ง ์ ๋ฆฌ๋ ๋ค์์ฃผ์ ๋ชฐ์์ ํ๋๊ฑธ๋ก...ใ