python学习(0)
python学习路径
python之禅
import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
美胜于丑。
显式优于隐式。
简单胜于复杂。
复杂总比复杂好。
平的比嵌套的好。
稀疏胜于稠密。
可读性计数。
特殊情况不足以打破规则。
尽管实用性胜过纯洁性。
错误永远不会悄悄地过去。
除非明确沉默。
面对歧义,拒绝猜测的诱惑。
应该有一种——最好只有一种——显而易见的方法来做到这一点。
不过,如果不是荷兰语的话,这种方式一开始可能并不明显。
现在总比没有好。
虽然从来没有比现在更好。
如果实现很难解释,那是个坏主意。
如果实现很容易解释,这可能是一个好主意。
名称空间是一个非常好的主意——让我们做更多的事情吧!
python改进提案
常见方法
title()
upper()
lower()
insert()
append()
pop()
remove() 只能删除第一个值
del
pass try-except-else 用于except表示什么也不执行
列表
sort () 永久排序,reverse = True倒序
sorted () 非修改 ,reverse = True倒序
reverse() 反转顺序,非倒序
len() 长度
min()
max()
sum()
in 判断是否在列表中
count() 出现次数
set() 集合,删除重复项
splite() 利用空格分隔单词
python关键字
import keyword
print(keyword.kwlist)
[‘False’, ‘None’, ‘True’, ‘and’, ‘as’, ‘assert’, ‘async’, ‘await’, ‘break’, ‘class’, ‘continue’, ‘def’, ‘del’, ‘elif’, ‘else’, ‘except’, ‘finally’, ‘for’, ‘from’, ‘global’, ‘if’, ‘import’, ‘in’, ‘is’, ‘lambda’, ‘nonlocal’, ‘not’, ‘or’, ‘pass’, ‘raise’, ‘return’, ‘try’, ‘while’, ‘with’, ‘yield’]