摘要:#include #include #include"getpasswd.h" char passwd[12] = ""; char *getpasswd() { char c; int i = 0; while ((c=getch()) != '\r') { if(c==8) i--; ...
阅读全文
摘要:#include #include #include #include #include using namespace std; void fun(char *s){//通过形参返回字符串 strcpy(s, "hello"); } char *fun2(char *s){//另一种写法, strcpy(s, "hello"); return s;//返回形...
阅读全文
摘要:#include #include using namespace std; void main() { ofstream in; in.open("com.txt",ios::trunc); //ios::trunc表示在打开文件前将文件清空,由于是写入,文件不存在则创建 int i; char a='a'; for(i=1;i #include ...
阅读全文
摘要:class Student(object): pass s = Student() s.name = 'Michael' print(s.name) def set_age(self, age): self.age = age from types import MethodType s.set_age = MethodType(set_age, s) #给实例绑定一个方法 s...
阅读全文
摘要:class Student(object): pass s = Student() s.name = 'Michael' print(s.name) def set_age(self, age): self.age = age from types import MethodType s.set_age = MethodType(set_age, s) #给实例绑定一个方法 s...
阅读全文
摘要:#!usr/bin/env python3 #-*- coding: utf-8 -*- #使用模块 'a test module' __author__ = 'Michael Liao' import sys def test(): args = sys.argv if len(args) == 1: print('Hello, World') ...
阅读全文
摘要:t = int('123445') print(t) t = int('123', 4) print(t) #23 t = int('123', base = 8) print(t) #83 t = int('12', 16) print(t) #18 def int2(x, base = 8): return int(x, base) t = int2('12') print(...
阅读全文
摘要:先讲一下python中的@符号 看下面代码 上面代码相当于
阅读全文
摘要:#返回函数 def lazy_sum(*args): def sum(): sum = 0 for i in args: sum += i return sum return sum #当我们调用lazy_sum()时,返回的并不是求和结果,而是求和函数: t = lazy_sum(1, 4, 5, 6) #...
阅读全文
摘要:reduce把一个函数作用在一个序列[x1, x2, x3, ...]上,这个函数必须接收两个参数,reduce把结果继续和序列的下一个元素做累积计算,其效果就是: 比方说对一个序列求和,就可以用reduce实现: 当然求和运算可以直接用Python内建函数sum(),没必要动用reduce。 但是
阅读全文
摘要:idea->写功能集合->画原型图、数据模型、业务流图->开发 每一步过程都是迭代的,需要让用户确认才能开始下一个步骤 和用户交流的过程中察言观色,让对方保持兴趣。要学会吸引/劝慰用户,但是不能强硬,让人觉得你是一个领袖,而非独裁者 写功能集合的时候需要给用户看的文档1:功能集(用词准确,减少歧义,
阅读全文
摘要:写一点上一节用到的东西 本节: 函数式编程就是一种抽象程度很高的编程范式,纯粹的函数式编程语言编写的函数没有变量,因此,任意一个函数,只要输入是确定的,输出就是确定的,这种纯函数我们称之为没有副作用。而允许使用变量的程序设计语言,由于函数内部的变量状态不确定,同样的输入,可能得到不同的输出,因此,这
阅读全文