![](https://img-blog.csdnimg.cn/78e8e8f8531d4630b508a591e9f09afb.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
python学习
文章平均质量分 57
python学习
xlxlxl_
这个作者很懒,什么都没留下…
展开
-
pip安装第三方包时下载速度太慢导致下载失败
可以加上镜像地址下载。国内常见镜像源:阿里云 http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/豆瓣(douban) http://pypi.douban.com/simple/清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/下载方原创 2022-02-15 15:54:44 · 431 阅读 · 0 评论 -
pip命令安装第三方包无法正常下载
新安装的python,pip命令安装第三方包时只显示collecting,没有下载过程,无法成功下载,也不能更新pip。是因为python版本太低的原因,目前试验过的3.4.x版本和3.5.x版本都有这个问题,卸载重装python到3.6.x版本以后功能就正常了。...原创 2022-02-15 15:38:46 · 1716 阅读 · 2 评论 -
python学习9-模块、包和程序
在终端窗口运行python程序:python python文件名.py模块导入模块import 模块 (模块是不带.py拓展的其他python文件名);用report.函数名,就可以在主程序中使用子程序的函数#report1.py 子程序def get_description(): from random import choice poss = ['rain','snow','sleet','fog','sun','who konws'] return c.原创 2021-10-15 10:37:58 · 169 阅读 · 0 评论 -
print函数
python字符串格式化符号: 符 号 描述 %c 格式化字符及其ASCII码 %s 格式化字符串 %d 格式化整数 %u 格式化无符号整型 %o 格式化无符号八进制数 %x 格式化无符号十六进制数 %X 格式化无符号十六进制数(大写) %f 格式化浮点数字,可指定小数点后的精度 %...转载 2021-10-14 11:04:22 · 157 阅读 · 0 评论 -
python学习7-函数
定义函数def 函数名(函数参数):函数名只能以字母或下划线_开头,只能含有字母、数字、下划线;函数不显式调用return函数,会默认返回None无参数无操作函数def nothing(): passnothing()无参数有操作函数def print_ss(): print("pppp")print_ss()#pppp无参数有返回值函数def agree(): return Falseif agree(): print(".原创 2021-10-13 23:05:53 · 173 阅读 · 0 评论 -
python学习6-推导式
列表推导式简单形式:[expression for item initerable][列表生成值 for 循环变量 in 迭代对象]>>> list1 = [number for number in range(1,5)]>>> list1[1, 2, 3, 4]>>> list1 = [number+1 for number in range(1,5)]>>> list1[2, 3, 4, 5]简单形.原创 2021-10-12 19:57:02 · 65 阅读 · 0 评论 -
python学习5-判断、循环语句
# 单行注释""" """或''' ''' 多行注释#这是单行注释"""这是多行注释"""\ 连接符,连接两行代码>>> a = "aaaaa\... 1111">>> a'aaaaa1111'原创 2021-10-12 16:20:40 · 104 阅读 · 0 评论 -
python学习4-集合
集合中的元素不可以重复;set() 创建集合,{}创建集合,空集合用set()表示,{}表示空字典>>> set1 = set()>>> set1set()>>> set2 = {1,2,3,4,5,6}>>> set2{1, 2, 3, 4, 5, 6}>>> set3 = {1,1,1,2,3,4,3}>>> set3{1, 2, 3, 4}set() 将其他类型原创 2021-10-11 10:43:41 · 80 阅读 · 0 评论 -
python学习3-字典
创建字典字典内元素是键值对的形式,可进行增加、删除、修改。用{}创建字典,格式:{key:value};有时候创建会出错,检查是否在每一个元素最后都加上了,(列表、元组也可以加)>>> empty_dict = {}>>> empty_dict{}>>> dict1 = {"day":"one,two",... "222":"33dg",... "key2":"terr",... "key2":"1,2,3,4",...原创 2021-10-10 14:14:28 · 92 阅读 · 0 评论 -
python学习2-列表、元组
列表使用 [] 或 list() 创建。>>> empty_list = []>>> empty_list = [ ]>>> weekdays = ["Monday","Tuesday","Wednesday","Tuesday", "Friday"]>>> empty__list = list()>>> empty__list[]>>> empty_list[]&...原创 2021-09-26 17:44:31 · 117 阅读 · 0 评论 -
python学习1-数字、字符串、变量
type(thing) #获取thing的数据类型变量名只能包含:小写字母、大写字母、数字、下划线,不能以数字开头。python保留的关键字:['False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'f..原创 2021-08-27 10:41:48 · 285 阅读 · 0 评论