0
点赞
收藏
分享

微信扫一扫

python 进阶

有点d伤 2022-03-14 阅读 74

python 进阶

python

编解码

https://www.bilibili.com/video/BV1EE41187jY?p=41&spm_id_from=pageDriver

\r \n

  • \r 回到本行开头,覆盖本行本容
  • \n 本行的下一行开头

argparse

https://blog.csdn.net/the_time_runner/article/details/97941409
https://www.cnblogs.com/lindaxin/p/7975697.html
https://zhuanlan.zhihu.com/p/56922793
https://docs.python.org/zh-cn/3/library/argparse.html#dest

*args **kwargs

https://www.zhihu.com/search?q=python%20args%20kwargs&utm_content=search_suggestion&type=content

装饰器

更复杂的可以吧装饰想想成顶层(最外层)的函数

链接还要再看
https://www.zhihu.com/search?type=content&q=Python%20%E8%A3%85%E9%A5%B0%E5%99%A8
https://www.runoob.com/w3cnote/python-func-decorators.html

def decorator(fun):
	def wrapper(*args,**kwargs):
		# some wrapper op
		fun(*args,**kwargs)
		return xxx
	return wrapper

@decorator #没有括号
def fun(*args):
	#some fun op
	pass
	return xxx

#执行
fun(*args) 
# output: 
# some wrapper op
# some fun op


def decorator_wrapper(decorator_param):
	def decorator(fun):
		def wrapper(*args,**kwargs):
			#some warpper op
			fun(*args,**kwargs)
			return in_warpper_output
		return warpper
	return decorator

@decorator_wrapper(decorator_param) #没有括号
def fun(*args):
	#some fun op
	pass
	return xxx


生成器与迭代器

https://www.zhihu.com/search?q=%E7%94%9F%E6%88%90%E5%99%A8%E5%92%8C%E8%BF%AD%E4%BB%A3%E5%99%A8&utm_content=search_suggestion&type=content
生成器实现了迭代器协议,并实现了延时操作
yield一次返回一个值,然后挂起,yield只能遍历完整数据一次

https://zhuanlan.zhihu.com/p/21101992
http://www.python3.vip/tut/py/basic/18/
https://www.runoob.com/note/33690
https://www.zhihu.com/question/319032154/answer/1485734871(重要)
https://zhuanlan.zhihu.com/p/165224592(重要)
https://www.zhihu.com/search?type=content&q=python%20%E9%9D%99%E6%80%81%E6%96%B9%E6%B3%95%E5%92%8C%E7%B1%BB%E6%96%B9%E6%B3%95
类的公共属性和实例属性
实例属性 init

@staticmethod 静态方法 不能访问实例属性,静态方法没有参数要求
实例方法,参数self
@classmethod 类方法,参数cls

类名调用静态方法可以
类名调用实例方法要传实例对象
类名调用类方法可以
对象调用静态方法可以
对象调用实例方法可以
对象调用类方法可以

静态方法不能访问(修改)实例方法和实例属性,只修改类属性和类方法(修改类属性后,实例中的累属性也会被修改)

继承

子类也会调用父类的__init__

super
https://www.zhihu.com/search?type=content&q=python%20super

file

https://blog.csdn.net/weixin_42148784/article/details/114292416?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-4&spm=1001.2101.3001.4242

进程

https://www.zhihu.com/question/25532384

正则表达式

https://www.cnblogs.com/shenjianping/p/11647473.html(全)
https://www.cnblogs.com/selina1997/p/10208660.html(对于量词的解释)
https://www.jianshu.com/p/39fb062abbe0
https://www.runoob.com/python3/python3-reg-expressions.html

socket

https://www.zhihu.com/search?type=content&q=socket(大林 没看完)
https://www.bilibili.com/video/BV1eg411G7pW?from=search&seid=16916536270625157990

__call__方法

https://zhuanlan.zhihu.com/p/184979212
https://blog.csdn.net/IAlexanderI/article/details/68946731

__repr__方法

http://c.biancheng.net/view/2367.html

__dict__方法

https://www.zhihu.com/question/302703968

__annotation__方法

https://blog.csdn.net/dongfuguo/article/details/105103472
https://blog.csdn.net/poblg/article/details/103583671

python 变量注释写法

a:str=[] # 并不是强制类型转换

dict.update方法

http://c.biancheng.net/view/4386.html

hasattr

用于判断类属性的存在
https://www.cnblogs.com/cenyu/p/5713686.html

相对导入绝对导入

https://www.cnblogs.com/ArsenalfanInECNU/p/5346751.html
https://www.zhihu.com/search?type=content&q=attempted%20relative%20import%20with%20no%20known%20parent%20package(重要)

python3不写__init__也可以

name

https://zhuanlan.zhihu.com/p/57309137
https://blog.csdn.net/wosind/article/details/90728198

logging

https://www.bilibili.com/video/BV1sK4y1x7e1?from=search&seid=7836820017728226452

运算优先级

https://blog.csdn.net/weixin_44001521/article/details/102560056
逻辑运算符优先级

a=b=c

| & and or

max

问题

  • 闭包
  • 作用域
  • 嵌套
  • 工厂方法
举报

相关推荐

0 条评论