Python Notes 學習筆記 📝
有時候想找一個東西(寫法),但當下卻忘記關鍵字,所以整理一篇學習筆記,要找資料的時候也比較方便。
有些是網路上找的範例,然後自己再修修改改,或是去參考一些 Python-Patterns , Python Anti-Patterns 。
範例程式會盡量遵守 PEP 8 -- Style Guide for Python Code
歡迎大家一起討論~
筆記會持續更新~
repr_tutorial.py - repr tutorial
assert_tutorial.py - assert tutorial
str_find_tutorial.py - str_find tutorial
attribute_obj.py - setattr() , getattr() , hasattr()
check_is_in_list.py - 檢查目標是否在 list 裡
datetime_tutorial.py - datetime , monthrange , timestamp
defaultdict_tutorial.py - defaultdict
counter_tutorial.py - counter
namedtuple_tutorial.py - namedtuple
dictionary_using_items.py - dictionary.items()
dictionary_get.py - dictionary get()
set_tutorial.py - set tutorial
dictionary_update.py - dictionary update()
tuple_tutorial.py - tuple
eafp.py - EAFP coding style
enumerate_tutorial.py - enumerate
filter.py - filter
format.py - format
function_default.py - function default value
isdigit.py - isdigit()
isinstance.py - check type
join.py - join
json_tutorial.py - json.loads()
kwargs.py - **kwargs , *arg - youtube tutorial - What is **kwargs *args
lambda.py - lambda
list_tutorial.py - list tutorial
loop_if_else_break.py - if not add break , will run more meaningless loop
map_tutorial.py - map tutorial
OrderedDict_tutorial.py - OrderedDict
MappingProxyType_tutorial.py - MappingProxyType
parse_dateutil.py - dateutil.parser
property_decorator.py - property_decorator
raise_an_exception_from_function_call.py - it is better to raise an exception that can be caught by the caller instead.
range.py - range
reduce.py - reduce
setdefault_tutorial.py - setdefault
sort.py - sort
sorted.py - sorted
iter_tutorial.py - iter tutorial
iter_another_trick_tutorial.py - iter another trick tutorial
__iter__tutorial - __iter__
tutorial
yield_tutorial.py- yield tutorial
yield_from_tutorial.py- yield from tutorial
Enum_tutorial.py- Enum tutorial
__str__tutorial.py - __str__
tutorial
strtobool_tutorial.py - strtobool
underscore_variable.py - underscore variable
use_unpacking.py - use unpacking
using_a_mutable_default_value_as_an_argument.py - Be careful with mutable default arguments ( lists or dictionaries ) - youtube tutorial
zip_tutorial.py - zip
staticmethod_tutorial.py - staticmethod tutorial
classmethod_tutorial.py - classmethod tutorial
decorator_tutorial.py - decorator 裝飾器
with_as_tutorial.py - with as tutorial
context_manager_tutorial.py - context manager
suppress_tutorial.py - context manager - suppress - youtube tutorial - python 教學 - 什麼是 suppress
configparser_tutorial - ConfigParser tutorial,可參考 https://docs.python.org/3/library/configparser.html
__len__tutorial.py - __len__
tutorial
decimal_tutorial.py - decimal tutorial
copy_tutorial.py - copy_tutorial
sum_tutorial.py -sum_tutorial
built-in-functions_tutorial.py - Built-in Functions tutorial
division_operators_tutorial.py - division operators tutorial
reduce_use_for_loop_tutorial_1.py - reduce_use_for_loop_tutorial_1
reduce_use_for_loop_tutorial_2.py - reduce_use_for_loop_tutorial_2
nested_loop_tutorial.py - nested_loop_tutorial
dict.fromkeys_tutorial.py - dict.fromkeys tutorial
escape_tutorial.py - html.parser ( escape ) tutorial
pickle_tutorial.py - pickle tutorial
zipfile_tutorial.py - zipfile tutorial
unicodedata_tutorial.py - unicodedata ( control character ) tutorial
translate_tutorial.py - translate tutorial
re_tutorial.py - re tutorial
is_integer_tutorial.py - float is_integer tutorial ( TestCase )
remove_trailing_zeros_tutorial.py - decimal remove trailing zeros tutorial ( TestCase )
itemgetter_tutorial.py - itemgetter tutorial
groupby_tutorial.py - itertools groupby tutorial
groupby_tutorial_find_consecutive numbers.py - find consecutive numbers in list by groupby tutorial
python-decouple-tutorial - python decouple tutorial
dj_database_url_tutorial - dj-database-url tutorial ( for django )
pandas_tutorial - pandas tutorial
random_tutorial.py - random tutorial
__call__tutorial.py - __call__
tutorial - youtube tutorial - What is the __call__
in python
queue_tutorial.py - queue tutorial
methodcaller_tutorial - methodcaller tutorial - youtube tutorial - python 教學 - 什麼是 methodcaller
str_startswith_tutorial.py - str.startswith() tutorial
logging_tutorial.py- logging tutorial
operator_add_tutorial.py - operator.add tutorial
operator_mul_tutorial.py - operator.mul tutorial
itertools_tutorial.py - itertools tutorial
itertools_islice_tutorial.py - itertools.islice tutorial
itertools_tee_tutorial.py - itertools.tee tutorial
bytesio_tutorial.py - bytesio tutorial
stringio_tutorial.py - stringio tutorial
functools_partial_tutorial.py - functools.partial tutorial
try_except_tutorial.py - try except tutorial
user_defined_exceptions_tutorial.py - User-defined Exceptions tutorial
weakref_tutorial.py - weakref tutorial
mock_tutorial - mock 教學
python_circular_import - youtube tutorial - What is Python Circular Imports
What happens when you type an URL in the browser and press enter - youtube tutorial - What happens when you type an URL in the browser and press enter
cap theorem - youtube tutorial - What is CAP theorem
what is the classmethod and staticmethod
what is the functools.lru_cache
what is the if __name__ == '__main__'
in python
what is private and protected attribute
what is the python interpreter
type-hints-tutorial - PEP 484 Type Hints 介紹 - youtube tutorial - PEP 484 Type Hints 介紹
vcr-tutorial - Youtube Tutorial - vcrpy 介紹教學 - 輕鬆把 request 錄下來
freezegun_tutorial.py - mock datetime
decorator_lib.py - decorator lib tutorial
pytest_tutorial - pytest 教學
flake8 - linter 工具
black - 自動排版工具
isort - 排序 import 套件
pipx - 類似 linux 中的 apt, 更方便管理套件. - youtube tutorial - python 套件介紹 - pipx, flake8, black, isort
指定 python 版本
pipx install --python python3.8 flake8
查看目前安裝套件
pipx list
commitizen and pre-commit - 規格化 commit 以及 pre-commit
基本上,每個 python 檔案都可以直接執行。
python xxxx.py
範例
python defaultdict_tutorial.py
- Python 3.8.2
文章都是我自己研究內化後原創,如果有幫助到您,也想鼓勵我的話,歡迎請我喝一杯咖啡:laughing:
綠界科技ECPAY ( 不需註冊會員 )
歐付寶 ( 需註冊會員 )
MIT license