随笔分类 -  python编程从入门到实践

Eric Matthes
自动保存图表
摘要:import matplotlib.pyplot as plt x_values = range(1,1001) y_values = [x ** 2 for x in x_values] fig,ax = plt.subplots() ax.scatter(x_values,y_values,s= 阅读全文

posted @ 2021-03-14 00:08 winecork 阅读(71) 评论(0) 推荐(0)

自定义颜色
摘要:自定义颜色 import matplotlib.pyplot as plt x_values = range(1,1001) y_values = [x ** 2 for x in x_values] fig,ax = plt.subplots() ax.scatter(x_values,y_val 阅读全文

posted @ 2021-03-14 00:05 winecork 阅读(139) 评论(0) 推荐(0)

自动计算数据
摘要:import matplotlib.pyplot as plt x_values = range(1,1001) y_values = [x ** 2 for x in x_values] fig,ax = plt.subplots() ax.scatter(x_values,y_values,s= 阅读全文

posted @ 2021-03-14 00:00 winecork 阅读(30) 评论(0) 推荐(0)

scatter()绘制一些列点
摘要:import matplotlib.pyplot as pltx_values = [1,2,3,4,5]y_values = [1,4,9,16,25] # y_values = [x ** 1 for x in x_values]fig,ax = plt.subplots() ax.scatte 阅读全文

posted @ 2021-03-13 23:54 winecork 阅读(75) 评论(0) 推荐(0)

用scatter()绘制散点图
摘要:import matplotlib.pyplot as plt fig,ax = plt.subplots() ax.scatter(2,4) plt.show() 阅读全文

posted @ 2021-03-13 23:51 winecork 阅读(105) 评论(0) 推荐(0)

使用内置款式
摘要:import matplotlib.pyplot as plt input_values = [1,2,3,4,5] squares = [1,4,9,16,25] plt.style.use('ggplot') # 绘制图表时使用款式ggplot fig,ax = plt.subplots() a 阅读全文

posted @ 2021-03-13 23:34 winecork 阅读(58) 评论(0) 推荐(0)

校正图形
摘要:由于之前绘制squares列表图表时,图上点位与坐标轴刻度对应不上,特此修复 import matplotlib.pyplot as plt input_values = [1,2,3,4,5] # 新加变量input_values,为将与squares组成横纵坐标点 squares = [1,4, 阅读全文

posted @ 2021-03-13 23:28 winecork 阅读(55) 评论(0) 推荐(0)

修改标签文字和线条粗细
摘要:import matplotlib.pyplot as plt squares = [1,4,9,16,25] fig,ax = plt.subplots() ax.plot(squares,linewidth=15) # 设置折线宽度15 ax.set_title("Title",fontsize 阅读全文

posted @ 2021-03-13 23:12 winecork 阅读(245) 评论(0) 推荐(0)

matplotmib绘制简单折线图
摘要:安装matplotlib模块 $ python -m pip install matplotlib 绘制简单折线图 import matplotlib.pyplot as plt # 导入模块matplotlib并起别名plt,方便调用 squares = [1,4,9,16,25] # 创建列表, 阅读全文

posted @ 2021-03-13 22:56 winecork 阅读(167) 评论(0) 推荐(0)

修改类的属性值
摘要:#直接修改属性的值# -*- coding:utf-8 -*- class Car(): def __init__(self,make,model,year): self.make = make self.model = model self.year = year self.odometer_re 阅读全文

posted @ 2020-01-29 00:17 winecork 阅读(395) 评论(0) 推荐(0)

使用pip安装matplotlib
摘要:失败: >python -m pip install --user matplotlib.whl #本地安装失败 >pip install matplotlib #超时 成功: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some- 阅读全文

posted @ 2019-02-21 16:20 winecork 阅读(443) 评论(0) 推荐(0)

函数
摘要:定义做衣服函数,传参数大小和印在Tee上的字 return python将非空字符串解读为True 结合while 任意数量参数 导入整个模块 文件pizza.py内容 文件making_pizza.py内容 输出结果: 导入特定函数:from module_name import function 阅读全文

posted @ 2019-01-14 20:53 winecork 阅读(183) 评论(0) 推荐(0)

用户输入和while循环
摘要:input() 求模运算符:%,它将两个数相除并返回余数 余数如果是0,可利用这点来判断奇/偶数 while循环:不断地运行,知道指定的条件不满足为止。 标记 break continue 注:如果命令行出现无限循环,Ctrl+C退出 验证新注册用户,将未验证用户移动到已验证用户列表中 删除列表中所 阅读全文

posted @ 2019-01-11 23:19 winecork 阅读(146) 评论(0) 推荐(0)

字典
摘要:建立空字典 删除键值对 遍历键值对 遍历字典中的所有键 遍历字典中的所有值 嵌套: 字典中嵌套列表:打印每人最爱的语言 字典中嵌套字典: 阅读全文

posted @ 2019-01-11 18:19 winecork 阅读(134) 评论(0) 推荐(0)

if语句
摘要:比较: ==、!=、<、<=、>、>= in、not in and、or if语句: if if-else if-elif-else 简写 阅读全文

posted @ 2019-01-11 13:22 winecork 阅读(133) 评论(0) 推荐(0)

操作列表
摘要:遍历列表 range() #生成一系列数字,可添加参数控制步长,如:range(1,5,2)输出:1,3 list() #输出一个列表 min(),max(),sum() 列表解析 切片 元组:不能修改的列表,用圆括号表示,如(1,2,3) 阅读全文

posted @ 2019-01-10 22:47 winecork 阅读(127) 评论(0) 推荐(0)

列表简介
摘要:#从列表中删除元素 del motorcycles[0] pop() #弹出。删除列表中最后一个元素,使用被删除的元素,应用场景:获取被干死一个外星人坐标,并在这个坐标位置显示爆炸效果。 pop(索引值) #删除索引位置的值 remove() #根据值删元素,如果列表中出现多次,只能删除第一个 so 阅读全文

posted @ 2019-01-10 21:47 winecork 阅读(114) 评论(0) 推荐(0)

变量和简单数据类型
摘要:变量: 1.只能包含字母、数字和下划线。字母和下划线开头; 2.不能包含空格; 3.不要将关键字和函数名做变量名; 4.简短有描述性; 5.慎用小写字母l(L)和大写O 注释符号 # python之禅 阅读全文

posted @ 2019-01-10 20:38 winecork 阅读(133) 评论(0) 推荐(0)

配置编辑器geany
摘要:安装geany编辑器后,“文件”-“另存为”- “生成”-“设置生成命令”- Compile:C:\Python37\python -m py_compile "%f" Execute:C:\Python37\python "%f" 确定。 写入: 按F5执行,结果如下: 阅读全文

posted @ 2019-01-10 15:21 winecork 阅读(451) 评论(0) 推荐(0)

导航