Meet Python: little notes】的更多相关文章

Source: http://www.liaoxuefeng.com/ ♥ Function In python, name of a function could be assigned to a variable, for example: >>> a = abs; >>> a(-12) 12 function definition: def funtion_name(input_variable): function body return variables #…
From this blog I will turn to Markdown for original writing. Source: http://www.liaoxuefeng.com/ ♥ list a list could be accessed using positive number (start from 0) in sequence or negative number in reverse sequence. Note that square brackets should…
Source: http://www.liaoxuefeng.com/ ❤ Escape character: '\' - '\n': newline; - '\t': tab; - '\\': \; - r'...': no transferring for contents within single quotes; - '''...''': multiple lines within triple quotes: could start a new line with ENTER dire…
Source: http://www.liaoxuefeng.com/ ♥ Slice Obtaining elements within required range from list or tuple (The results remain the same type as the original one.). >>> L = list(range(100)) >>> L [0, 1, 2, ..., 99] >>> L[:3] # Acces…
python 100day notes(2) str str2 = 'abc123456' print(str1.endswith('!')) # True # 将字符串以指定的宽度居中并在两侧填充指定的字符 print(str1.center(50, '*')) # 将字符串以指定的宽度靠右放置左侧填充指定的字符 print(str1.rjust(50, ' ')) # 检查字符串是否由数字构成 print(str2.isdigit()) # False # 检查字符串是否以字母构成 prin…
Python读书笔记:70个注意的小Notes 作者:白宁超 2018年7月9日10:58:18 摘要:在阅读python相关书籍中,对其进行简单的笔记纪要.旨在注意一些细节问题,在今后项目中灵活运用,并对部分小notes进行代码标注.(本文原创,转载注明出处:Python读书笔记:70个注意的小Notes  ) <Python读书笔记> 1 python始终记录变量最新值.2 变量应简短且具有描述性,如student_name等.3 变量名推荐小写.4 单双引号括起来的,字符串可以包含引号和…
Python 使用 lambda 来创建匿名函数. lambda这个名称来自于LISP,而LISP则是从lambda calculus(一种符号逻辑形式)取这个名称的.在Python中,lambda作为一个关键字,作为引入表达式的语法.想比较def函数,lambda是单一的表达式,而不是语句块! 所谓匿名,意即不再使用 def 语句这样标准的形式定义一个函数. lambda 只是一个表达式,函数体比 def 简单很多. lambda的主体是一个表达式,而不是一个代码块.仅仅能在lambda表达式…
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 字符串处理.py >>作者: liu yang >>邮箱: liuyang0001@outlook.com >>博客: www.cnblogs.com/liu66blog '''''''''''''''''''''''''''''''''''''''…
在 Python 2.5 中, with 关键字被加入.它将常用的 try ... except ... finally ... 模式很方便的被复用.看一个最经典的例子: with open('file.txt') as f: content = f.read() 在这段代码中,无论 with 中的代码块在执行的过程中发生任何情况,文件最终都会被关闭.如果代码块在执行的过程中发生了一个异常,那么在这个异常被抛出前,程序会先将被打开的文件关闭. 再看另外一个例子. 在发起一个数据库事务请求的时候,…
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 键盘控制.py >>作者: liu yang >>邮箱: liuyang0001@outlook.com >>博客: www.cnblogs.com/liu66blog ''''''''''''''''''''''''''''''''''''''''…