Python
hello_smu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python高级特性
# ## Python 高级特性from collections import Iterablefrom collections import Iterator# #切片# list切片L = list(range(100))print(L[0:3]) # 取前3个元素print(L[:3]) # 取前3个元素print(L[4:9]) # 取第4到第9位元素print(原创 2017-01-15 11:48:09 · 254 阅读 · 0 评论 -
Python基本语法
###字符串##常用占位符# %d 整数# %f 浮点数# %s 字符串a=72;b=85;r=(b-a)/a*100;print('保留两位小数的百分比为:%.2f%%.'%r)###list和tuple##list为有序集合,可随意添加和删除其中的元素newlist=['A','B','C','D','E','F','G','H']#list增加元素newlis原创 2017-01-09 21:18:16 · 275 阅读 · 0 评论 -
Python函数—参数
# ##函数的参数# #位置参数 调用时传入的值按照顺序赋值给函数def power(x, n): s = 1 for i in range(1, n + 1): s = s * x return sprint('位置参数的调用:')print(power(2, 3))# #默认参数def power(x, n=2): s原创 2017-01-10 19:59:44 · 290 阅读 · 0 评论 -
Python高阶函数——map/reduce/filter/sorted
# ## 高阶函数from functools import reduceprint(abs(-10))print(abs) # 输出# 函数本身可以赋值给变量f = absprint(f)print(f(-19))# #传入函数# 将函数作为参数传入另一个函数def add(x, y, f): return f(x) + f(y)print( a原创 2017-01-20 12:44:59 · 501 阅读 · 0 评论
分享