python code(1)
from collections import UserList
class MthChianList(UserList):
def filter(self,predicste):
return MthChianList(elem for elem in self if predicste(elem))
def map(self,mapper):
return MthChianList(mapper(elem) for elem in self)
def for_each(self,action):
for elem in self:
action(elem)
lt=MthChianList(['A','B','c','d','e','F'])
lt.filter(str.islower).map(str.upper).for_each(print)
python code(1)的更多相关文章
- Exploring Python Code Objects
Exploring Python Code Objects https://late.am/post/2012/03/26/exploring-python-code-objects.html Ins ...
- 机器学习算法实现(R&Python code)
Machine Learning Algorithms Machine Learning Algorithms (Python and R) 明天考试,今天就来简单写写机器学习的算法 Types Su ...
- How to run Python code from Sublime
How to run Python Code from Sublime,and How to run Python Code with input from sublime Using Sublime ...
- Python code 提取UML
Python是一门支持面向对象编程的语言,在大型软件项目中,我们往往会使用面向对象的特性去组织我们的代码,那有没有这样一种工具,可以帮助我们从已有代码中提取出UML图呢?答案是有的.以下,我们逐个介绍 ...
- PEP 8 – Style Guide for Python Code
原文:PEP 8 – Style Guide for Python Code PEP:8 题目:Python代码风格指南 作者:Guido van Rossum, www.yszx11.cnBarry ...
- Change the environment variable for python code running
python程序运行中改变环境变量: Trying to change the way the loader works for a running Python is very tricky; pr ...
- python code
执行动态语句 执行字符串中的代码 http://www.cnblogs.com/fanweibin/p/5418817.html #!usr/bin/env python #coding:utf-8 ...
- Python——Code Like a Pythonista: Idiomatic Python
Code Like a Pythonista: Idiomatic Python 如果你有C++基础,那学习另一门语言会相对容易.因为C++即面向过程,又面向对象.它很底层,能像C一样访问机器:它也很 ...
- python code 1_username registration & login
This tiny program consists of 2 parts - registration and login. In the part of registration, the key ...
- python code practice(二):KMP算法、二分搜索的实现、哈希表
1.替换空格 题目描述:请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 分析: 将长度为 ...
随机推荐
- 微信小程序开发——开发者工具无法输入中文的处理
问题模块 框架类型 问题类型 操作系统 工具版本 开发者工具 小程序 Bug Windows v.02.1810290 异常描述: 无法输入中文,偶现,但是概率有点高,重启,重装,更新版本等等都未解决 ...
- 【go语言实现服务器接收http请求以及出现泄漏时的解决方案】
一.关于基础的程序的实现 刚开始的时候程序是这样实现的: // Hello package main import ( "database/sql" "fmt" ...
- day 23 网络编程
C/S架构 Client与Server B/S架构 Browser与Server windows上查看端口占用情况 netstat -a OSI七层模型: 其他略...
- Quartz代码及配置详解(转)
Quartz可以用来做什么? Quartz是一个任务调度框架.比如你遇到这样的问题 想每月25号,信用卡自动还款 想每年4月1日自己给当年暗恋女神发一封匿名贺卡 想每隔1小时,备份一下自己的爱情动作片 ...
- 实现mapper接口注入的两种方式,以及后台的使用区别
1.使用模板方式: <!--使用模板类实现mybatis --> <bean id="sqlSession" class="org.mybatis.sp ...
- xss测试用例
alert(1)// 'alert(1)// '>alert(1)// >alert(1)// "alert(1)// ">alert(1)// alert(1) ...
- netcore webapi 用户 'IIS APPPOOL\无托管代码' 登录失败
配置在iis上,除了环境配置错误的原因还有一种可能是连接字符串的问题,iis要求使用sql server的sa或者其他登录用户. ps:连接字符串: "Default": &qu ...
- 1.git使用入门之基本的更新提交操作
在项目开发中使用git的规范,避免因为不规范的操作带来额外的工作量 更行代码 git pull 提交代码 .查看状态 git status .添加到本地缓存 git add .(所有,也可以单个添加) ...
- Java并发-懒汉式单例设计模式加volatile的原因
懒汉式单例的double check.例一: class SingletonClass{ private static SingletonClass instance = null; private ...
- opencv 双边模糊,膨胀腐蚀 开 闭操作
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; int main(int argc, ...