07 2021 档案
摘要:三种方式: %s 所有版本都可用 str.format() 2.6以上都可用,推荐使用 f"" 3.5以上可用 %s 格式化输出: # 按位置传参,有几个%s后面就要传几个参数,多一个少一个都会报错 res = "my name is %s age is %s"%('wython',18) # 传一
阅读全文
摘要:匿名函数,顾名思义就是没有名字的函数 我们首先要知道一个普通函数需要具备哪些东西: def func(*args,**kwargs): # 函数名,参数 print("hello word") # 代码块 return 返回值 # 返回值 匿名函数关键字:lambda lambda x,y:x+y
阅读全文
摘要:读取文件实例: # 文件句柄 = open('文件路径','模式','编码') f = open('a.txt','r',encoding='utf-8') # 默认打开模式就是r模式 # 应用程序向操作系统发起系统调用open(...),操作系统打开文件返回一个文件句柄给应用,应用程序将文件句柄赋
阅读全文