Python练习-模块和初级面像对象
本部分练习Python模块和初级面像对象相关知识。练习代码如下: #!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a test module ' __author__ = 'OneCoder Lihz' import sys def test(): args = sys.argv print("args:", arg...
本部分练习Python模块和初级面像对象相关知识。练习代码如下: #!/usr/bin/env python3 # -*- coding: utf-8 -*- ' a test module ' __author__ = 'OneCoder Lihz' import sys def test(): args = sys.argv print("args:", arg...
本部门练习Python函数式编程,第二部分。 # 1. 返回函数、闭包 import functools import time def cal_sums(*args): def do_sum(): result = 0 for x in args: result += x return result ...
本部分练习Python函数式编程。练习高阶函数、map、reduce等常用函数。 # 1. 高阶函数 from functools import reduce f = abs print(f) print(f(-10)) def absadd(x, y, f): return f(x) + f(y) print(absadd(-3, -4, f)) # 2. map...
# 高级特性 # 1. 切片和列表生成器 from collections.abc import Iterable, Iterator list_one = list(range(10)) print(list_one[:3]) print(list_one[2:7]) print(list_one[-5:-1]) # 取后5个数 print(list_one[-5:]) # 取偶数 pr...
# Python demo for lihz # 1. Hello World print("Hello World Python") # 2. 输入输出 print("The quick brown fox", "jumps over the lazy dog") print("100", "+", "200", "=", 100 + 200) # name = input("What ...
更新节奏缓慢,因为每晚学习注意力不够集中,学习进展缓慢。本还给自己找了一大堆其他理由,但摸着良心问自己,似乎只有这个理由说的通。 想搞懂的太多,却始终没搞明白。先看一个用Netty编写的NIO Server的样例。 package com.coderli.nettylab.guide; import io.netty.bootstrap.ServerBootstrap; impor...
距离上一篇博文已经过去了半个多月。这期间有一周多的时间用在了准备单位举办的英语竞赛上。余下的时间沉迷于陪孩子玩耍和睡觉,日复一日。 当然,我也抽空学习了Java NIO(None-Blocking / New IO) 一些知识,现总结如下。 Java的非阻塞IO的原理是采用了操作系统的多路复用器机制,即在一个通道(channel)上,注册一个事件选择器(selector)及各种事件(读、...
2012年,由于项目的需要我第一次接触到了Netty,当时Netty还处于3.x版本。我用十几篇博文记录了自己自学Netty的过程,虽然内容浅薄,但没想到被各处转载,我想主要是因为当时Netty的资料确实较少的缘故。 五六年过去了,Netty早已发展到了4.x系列,好奇也好,求知也罢,我打算重学Netty,虽然严格来说,我已不是IT从业人员,但我仍希望保留对技术的热爱与追求。 学习Net...
Problem Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front el...
Problem Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 2^0 = 1 Example 2: Input: 16 Output: true Explanation: 2^4 = 16...