![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 81
python的常用基础知识
爱睡觉的小秋
这个作者很懒,什么都没留下…
展开
-
python入门(上)
python入门(上) 1.变量,运算符,数据类型 1.运算符:// 整除 ** 幂 2.逻辑运算符:and, or, not 3.位运算符:~取反, 4.三元运算符:small = x if x < y else y 5.其他运算符: in,not in,eg: letters=[ ‘A’,‘B’ ] if ‘A’ in letters print is ,is not, is, is not 对比的是两个变量的内存地址 ==, != 对比的是两个变原创 2021-08-02 19:22:36 · 95 阅读 · 0 评论 -
python入门(中)
python入门(中) 列表List 1.语法为 [1, 2, …, n]。 #创建一个普通列表 x = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] #利用range()创建列表 x = list(range(10)) print(x, type(x)) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] <class 'list'> #利用推导式创建列表 x = [i for i in range(1原创 2021-08-04 15:26:22 · 236 阅读 · 0 评论 -
python入门(下)
python入门(下) 一、函数 1.定义 def functionname (parameters): "函数文档字符串" functionsuite return [expression] 2.函数参数 1.默认参数 arg2 = v - 默认参数 = 默认值,调用函数时,默认参数的值如果没有传入,则被认为是默认值。 默认参数一定要放在位置参数 后面,不然程序会报错。 def functionname(arg1, arg2=v): 2.可变参数 *原创 2021-08-06 12:39:54 · 66 阅读 · 0 评论