自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(9)
  • 收藏
  • 关注

原创 13_Downloading_Data

CSV csv文件的读取 绘制最高最低温度折线图,绘制结果如下: 读取csv文件并提取其中数据进行绘图: import csv from datetime import datetime from matplotlib import pyplot as plt """ 使用csv.reader()读取csv文件得到迭代器 在遍历列表时调用enumerate可以得到两个返回值:元素的编号和元素的值 highs存储最高温度的统计数据 try-except-else结构处理数据缺失的情况 """.

2022-05-31 00:23:00 104

原创 12_data_visualization

Matplotlib Line Graph import matplotlib.pyplot as plt """列表默认为y轴的值,x轴默认为1,2,3,...""" squares = [1, 4, 9, 16, 25] plt.plot(squares, linewidth=5) """标题与坐标轴的参数设置""" plt.title("Square Numbers", fontsize=24) plt.xlabel("Value", fontsize=14) plt.ylabel("Squa

2022-05-30 13:31:43 207

原创 11_File&Test

Reading from a File 同一目录下: file_name = 'a.txt' with open(file_name) as file_object: contents = file_object.read() # string """ 读取同一目录下的a.txt文件 """ open函数打开文件,把文件读取到内存中,若不用close关闭文件,会导致文件容易被篡改。 使用with可以保证在程序跳出with时关闭文件,更为安全。 Relative Path 从pytho

2022-05-29 23:55:01 112

原创 10_Object-oriented_Programming

类 类名称的首字母要大写 类中__init__()方法在创建实例时自动运行。 self对应实例的名称,不同的实例有不同的属性和方法。 class Dog(): def __init__(self, name, age): self.name = name self.age = age def sit(self): print(self.name.title() + " is now sitting.") def rol

2022-05-29 22:21:59 93

原创 9_Conveniences

Itertools 迭代器是一个对象,可以通过next函数形成一个序列,直到不能迭代为止。 用途:生成虚拟的序列;节省内存空间 import itertools nums = itertools.count(0,2) print(next(nums)) print(next(nums)) print(next(nums)) """ 0 2 4 """ 利用for循环进行遍历: import itertools nums = itertools.count(0,2) for i in num

2022-05-29 21:17:36 59

原创 7_variable_scope&arbitary_arguments

Variable Scope module,class,def,lambda可以引入新的变量作用域。 if/elif/else/try/except/for/while不会引入新的变量作用域。 def test(): msg = 'I am from Shanghai.' print(msg) """ error """ 函数内外定义的变量互不相干,即使名称一样也不影响。 msg = 'I am from Shanghai.' def test(): msg = 'I am

2022-05-29 19:30:00 71

原创 6_functions&modules

if __name__=='__main__' 如果当前模块被加载到另一个模块中,if控制的语句就不会被运行,这样可以方便调试 """ pizza.py """ def make_pizza(size): print("Making a {}-inch pizza.".format(size)) if __name__ == '__main__': make_pizza(45) """ test.py """ import pizza pizza.make_pizza(30)

2022-05-29 17:01:02 62

原创 5_string

可变与不可变 Values are immutable.Thus, numbers, strings, tuples are immutable. What does it mean for immutable or mutable --- assignment, modification, reference 1.assignment variable ---> computer memory ---> object 2.modification how to modify an

2022-05-29 15:44:25 80

原创 4_dictionary&tuple

dictionary * 用于指定函数传入参数的类型。*用于参数前面,表示传入的多个参数将按照元组的形式存储,是一个元组。 def t1(param1, *param2): print(param1) print(param2) t1(1,2,3,4) # 1 # (2,3,4) 此外,*还可以解压参数列表: def t3(p1, p2): print(p1, p2) args = [1, 2] t3(*args) ​ # 1 2 **

2022-05-29 14:21:38 97

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除