摘要:
#没有名字的函数,定义函数的lambdaf1 = lambda x:x+1 #冒号前面参数值,后面是返回值ret =f1(1,2)print(ret)f1 = lambda a, b: 1 if a > b else 2 #可以下三元表达式f2 = lambda a, b: a + bret = f 阅读全文
posted @ 2021-10-15 14:14
王王的王
阅读(41)
评论(0)
推荐(0)
摘要:
#函数 方法 定义函数 简化代码,(函数有值,没被调用不会生效)def say_hello(): #函数名,定义函数 print("hello") #函数体say_hello() #调用函数:函数名加括号def crea_band_card(cound): #形参 形式参数,可以传多个参数,没限制, 阅读全文
posted @ 2021-10-15 14:14
王王的王
阅读(81)
评论(0)
推荐(0)
摘要:
# 可变类型 list dict set# 不可变类型 ser tuple int float bool,必须声明 global() 才能修改names=["赵琴","赵艳萍","小苗"] #这里面是全局变量def add_name(): name=input("name:") names.appe 阅读全文
posted @ 2021-10-15 14:06
王王的王
阅读(123)
评论(0)
推荐(0)
摘要:
import time#格式化好的时间#时间戳 从unix 元年到现在过了多少秒# print(time.time())#当前的时间戳# print(time.strftime('%Y-%m-%d %H:%M:%S'))#当前格式化好的时间,根据指定格式显示的#时间元组t=time.gmtime(2 阅读全文
posted @ 2021-10-15 14:05
王王的王
阅读(85)
评论(0)
推荐(0)
摘要:
1、cmd:简单快捷pip install pymysql未完待续 阅读全文
posted @ 2021-10-15 13:52
王王的王
阅读(84)
评论(0)
推荐(0)
摘要:
#导入模块原理import tools #方式一 #handler引用tools 导入模块的实质就是把这个python执行了一遍tools.mysql()print(tools.size)from tools import mysql,size #方式二mysql()print(size)#查找模块 阅读全文
posted @ 2021-10-15 09:57
王王的王
阅读(231)
评论(0)
推荐(0)
摘要:
#和系统相关的模块import osret=os.listdir(r"E:\Thz\day-1")#传一个路径,把路径列出来print(ret)os.path.getsize("大小")#获取文件大小os.path.join("e:","logs","a.txt") #自动拼路径 import os 阅读全文
posted @ 2021-10-15 09:56
王王的王
阅读(210)
评论(0)
推荐(0)
摘要:
#自带函数,不需要定义,直接就可以日常使用sum([1,2,3]) #int类型 求和min("123") #最小 字符串max([1,2,3]) #最大round(1,9842,2) #保留n位小数 后边写几保留几位小数sorted(s)#排序,它返回一个list 默认升序sorted(s,rev 阅读全文
posted @ 2021-10-15 09:54
王王的王
阅读(321)
评论(0)
推荐(0)

浙公网安备 33010602011771号