要一直走下去

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2018年7月6日

摘要: Lambda函数可以具有任意数量的参数,但只能有一个表达式。该表达式将被求值并返回 f = lambda x, y: x ** y # 返回x的y次方 f1 = lambda x: x + 1 # 返回x+ 我们通常使用Lambda函数作为高阶函数的参数,该函数以其他函数作为参数。匿名函数与内置函数 阅读全文
posted @ 2018-07-06 09:54 要一直走下去 阅读(291) 评论(0) 推荐(0) 编辑

摘要: 一、整型(int) # int对象初始化 x = 2 y = int(3) n = int("A3",12) # 运算符(+、-、*、/、//、%、**) ''' 相关的函数 ''' abs(x) #求绝对值 divmod(x,y) #求x/y的商和余数,返回元祖 pow(x,y) #求x的y次方 阅读全文
posted @ 2018-07-06 09:40 要一直走下去 阅读(230) 评论(0) 推荐(0) 编辑

摘要: 列表: L.append(x) # x追加到L尾部 L.count(x) # 返回x在L中出现的次数 L.extend(m) # Iterable m的项追加到L末尾 L += m # 功能同L.extend(m) L.index(x, start, end) # 返回x在列表L(或者L[start 阅读全文
posted @ 2018-07-06 09:40 要一直走下去 阅读(269) 评论(0) 推荐(0) 编辑

摘要: ''' logging模块: logging的日志可以分为 debug():Detailed information, typically of interest only when diagnosing problems. info():Confirmation that things are w 阅读全文
posted @ 2018-07-06 09:39 要一直走下去 阅读(233) 评论(0) 推荐(0) 编辑

摘要: 抛出异常写法: raise KeyError(obj) # obj可以为字符串,数字,元祖,列表,字典等任意类型。 ''' 异常处理格式 ''' try: pass except KeyError as e: print("key error..", e) except IndexError as 阅读全文
posted @ 2018-07-06 09:39 要一直走下去 阅读(146) 评论(0) 推荐(0) 编辑

摘要: Random模块: #!/usr/bin/env python #_*_encoding: utf-8_*_ import random print (random.random()) #0.6445010863311293 #random.random()用于生成一个0到1的随机符点数: 0 <= 阅读全文
posted @ 2018-07-06 09:36 要一直走下去 阅读(234) 评论(0) 推荐(0) 编辑

摘要: i+1: 当前的数量 300: 总数量 import sys print("下载中...") def process(curr, count): cursor_count = curr // int(count * 0.02) str = '>' * cursor_count + ' ' * (50 阅读全文
posted @ 2018-07-06 09:36 要一直走下去 阅读(102) 评论(0) 推荐(0) 编辑

摘要: 散装知识点1:Python简介解释型语言:解释,执行,解释,执行...编译型语言:编译,连接,执行解释型语言:解释器编译型语言:编译器,解释型语言:解释源码,不同平台使用不同的解释器就行编译型语言:不同平台编译成不同的机器码python2.4最普及的版本Python2.6、2.7是过渡版本Pytho 阅读全文
posted @ 2018-07-06 09:24 要一直走下去 阅读(230) 评论(0) 推荐(0) 编辑