随笔分类 - python
python 编程
摘要:import numpy as npprint (np.mean(my_list))def getmean(numericValues): return sum(numericValues)/len(numericValues) if len(numericValues) > 0 else floa
阅读全文
摘要:x = 5 if x > 6 : print("x is greater than six")elif x > 4 and x == 5: print("{}".format(x))else: print("x is not greater than four") 5 y = ['Jan','Feb
阅读全文
摘要:empty_dict = {}a_dict = {'one':1,'two':2,'three':3}print("{}".format(a_dict))print("{}".format(len(a_dict)))another_dict = {'x':'printer','y':5,'z':['
阅读全文
摘要:my_tuple = ('x','y','z')print("{}".format(my_tuple))print("{}".format(len(my_tuple)))longer_tuple = my_tuple + my_tupleprint("{}".format(longer_tuple)
阅读全文
摘要:a_list = [1,2,3]another_list = ['printer',5,['start','circle','9']]a_new_list = a_list[:] print("{}".format(a_new_list))a = 2 in a_listprint("{}".form
阅读全文
摘要:1.1 字符串函数 字符串可以包含在单引号、双引号、3个单引号、3个双引号之间。 split() --将一个字符串拆分成一个子字符串列表。 string1 = "My deliverable is due in may"string1_list1 = string1.split() string1_
阅读全文
摘要:import matplotlib.pyplot as plt import numpy as np pop = np.random.randint(0,100,100) pop n,bins,patches = plt.hist(pop,bins=20) plt.show()
阅读全文
摘要:数据可视化 # -*- coding:utf-8 -*-# 异常值处理import pandas as pdaimport numpy as npyimport matplotlib matplotlib.use('Agg')import matplotlib.pyplot as pylimport
阅读全文
摘要:在Python3.x中,我们可以使用urlib这个组件抓取网页,urllib是一个URL处理包,这个包中集合了一些处理URL的模块,如下:1.urllib.request模块用来打开和读取URLs;2.urllib.error模块包含一些由urllib.request产生的错误,可以使用try进行捕
阅读全文
摘要:正则表达式获取贴吧访问量 正则表达式学习2--豆瓣获取文章 url数据获取--异常值处理--新浪新闻获取文章 import urllib.requestimport refile=urllib.request.urlopen("https://read.douban.com/provider/all
阅读全文
浙公网安备 33010602011771号