- 博客(12)
- 收藏
- 关注
原创 有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月起每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少对?
根据上述表格得:f(n) - f(n-1) = (3b+2a) - (2b+a) = a+b = f(n-2)f(n) = f(n-1) + f(n-2)def fib(n): a, b= 1, 2 while n > 2: a, b = b, a + b n -= 1 return bn = 5 # 第五个月ret...
2019-12-26 13:23:41 629
原创 青蛙跳台阶和验证幂数的方法
# 一只青蛙一次可以跳上1级台阶,也可以一次跳上2级……它也可以一次跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。# 当跳1级台阶时,f(1) = 1;# 当跳2级台阶时,f(2) = f(1) + 1 = 2;# 当跳3级台阶时,f(3) = f(2) + f(1) + 1 = 4;# 当跳4级台阶时,f(4) = f(3) + f(2) + f(1) + 1 = ...
2019-12-25 18:45:20 256
原创 mysql按年.月,周,日,小时统计数据
https://www.cnblogs.com/jpfss/p/8759232.htmlhttps://blog.csdn.net/u014518337/article/details/88417741select DATE_FORMAT(gmt_created,'%H:00') hours, count(id) count from ticket_ticketrecord group ...
2019-12-20 18:40:42 174
原创 Python获取函数的参数的用途及实现方法(参数内省/Bob框架/inspect.signature)
# 一: 函数内省是什么""" 函数内省的例子: --->HTTP 微框架Bob, 简单说明: 路由知道你这个接口需要什么参数"""import [email protected]('/')def hello(person): return "hello %s"...
2019-12-20 17:21:49 1031
原创 mysql: 一个表清空后从1开始自增
alter table other_para AUTO_INCREMENT=1;# alter table 表名 AUTO_INCREMENT=你想要的初始值;
2019-12-20 11:53:59 129
原创 mysql让一个字段等于两个字段拼接
现有: 目标: # 实现方法:update purchase_goods set goods_name = concat(goods_id, ". ", goods_name) # update 表名 set 字段1 = concat(字段a , "任意字符串", 字段b)# 数据还原update purchase_go...
2019-12-20 11:50:03 3585
原创 Python判断字符串的构成
# istitle()print("How Are You".istitle()) # Trueprint("how are you".istitle()) # False# isspace 只有空格print(" ".isspace()) # Trueprint(" 132 ".isspace()) # False# isalpha 都是字母print("...
2019-12-16 15:26:12 767
原创 Python中的 and和or &和|
# 如果a,b是数值变量, 则&, |表示按位运算, and,or则依据是否非0来决定输出# print(1 & 2)# print(1 | 2)# print(0 and 2) # 有False返回False, 否则返回后一个# print(1 and 2)## print(1 or 2) # 2个都为True, 返回第一个## print(0 or ...
2019-12-16 14:41:42 606
原创 Python中的换位运算符
"""a = 100 二进制为: 01100100b = 200 二进制为: 11001000按位运算符: & 参与运算的两个值,如果两个相应位都为1,则该位的结果为1,否则为0 例: a & b = b'01000000' => 64 | 只要对应的二个二进位有一个为1时,结果位就为1 例: a...
2019-12-16 13:35:56 2487
原创 python十进制与二进制的转换
num2 = 100# 方式一:b_num = lambda num: "" if num == 0 else b_num(num // 2) + str(num % 2)ret = b_num(num2)print(ret)# 方式二:b_num2 = bin(num2)[2:] # bin()返回的值是 "0bxxxxx" 为了获得正常的二进制需要把"0b"去掉...
2019-12-16 11:01:36 2112 1
原创 python中三元表达式的几种写法
# 返回a和b中较大的一个def func(a, b): ret1 = a if a > b else b # 写法1, 如果a>b, ret1=a, 否则, ret1=b ret2 = {True: a, False: b}[a > b] # 写法2, 如果条件成立, ret2=True对应的值--> a, 反之, ret...
2019-12-12 17:05:28 740
原创 Mysql: 查询函数 like , find_ in_set, regexp ,locate , instr
# 1-精确查select * from t_news where locate("不要制造恐慌", TITLE); # 2-模糊查select * from t_news where TITLE LIKE "%不要制造恐慌%"; # 3-精准查 字段内容必须和字符串一样, 或者用英文","隔开select * from t_news where FIND_IN_S...
2019-12-10 18:13:29 517
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人