09 2018 档案
摘要:python 常用模块: time & datetime, random, os, sys, hashlib, re, json, configparse, logging 不常用: pickle,shelve
阅读全文
摘要:#!/usr/bin/python# -*- coding: utf-8 -*-import sys,logging,osimport re计算: s = '1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) -
阅读全文
摘要:# -*- coding: utf-8 -*-# 所有的生成器都是迭代器,所有的迭代器不一定都是生成器# 迭代器必须满足: 1、有iter()方法 2、有next()方法# for循环的工作: #1 调用iter()方法返回一个迭代器对象 #2 不断调用next()方法 #3 处理StopItera
阅读全文
摘要:# 列表生成器a = [x for x in range(10)]print(a)# 生成器对象的2种定义方法#1 def add(a): return a+ab = (add(x) for x in range(5))#2 yield# 生成器的3种访问方法#1 print(next(g))#2f
阅读全文
摘要:1、作用域 2、高阶函数 3、闭包import timedef logger(flag=False): def show_time(f): def inner(*args,**kwargs): start = time.time() f(*args,**kwargs) end = time.time
阅读全文
浙公网安备 33010602011771号