自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

翻译 数据分析世界地图

import pygalimport jsonimport pygal.maps.worldfrom pygal.style import LightColorizedStyle as LCS, RotateStyle as RSfilename = ‘population_data.json’with open(filename) as f:pop_data = json.load(...

2019-03-13 15:29:26 872

翻译 数据分析人口地图

import jsonimport pygal.maps.world将数据加载到一个列表中filename = ‘population_data.json’with open(filename) as f:pop_data = json.load(f)# 打印每个国家2010年的人数for pop_dict in pop_data:if pop_dict[‘Year’] == ‘...

2019-03-13 15:29:12 790

翻译 数据分析气温表

import csvimport matplotlib.pyplot as pltfrom datetime import datetimeimport timefilename = ‘sitka_weather_07-2014.csv’with open(filename) as f:reader = csv.reader(f)header_row = next(reader)d...

2019-03-13 15:28:59 451

翻译 数据分析掷色子

from random import randintimport pygalclass Die():“”“表示一个色子的类”""def __init__(self, num_sides=6): """默认色字为六面""" self.num_sides = num_sidesdef roll(self): &amp

2019-03-13 15:28:47 322

翻译 数据分析折线图

import matplotlib.pyplot as pltinput_values = [1, 2, 3, 4, 5]squares = [1, 4, 9, 16, 25]x_value = list(range(1, 1001))y_value = [x ** 2 for x in x_value]plt.plot(input_values,squares,linewidth=5)...

2019-03-13 15:28:25 1853

翻译 数据分析随机漫步

from random import choiceimport matplotlib.pyplot as pltclass Randonmwalk():“”“一个生成随机漫步数据的类”""def __init__(self, num_points=5000): """初始化随机漫步的属性""" self.num_points =

2019-03-13 15:27:36 253

翻译 数据分析bit

import jsonfrom collections import defaultdictfrom collections import Counterfrom pandas import DataFrame, Seriesimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltpath = ‘exam...

2019-03-13 15:27:08 242

原创 python14——2day网络服务器

网络小型服务器import sockets = socket.socket()host = socket.gethostname() # 获取主机名port = 1234s.bind((host, port))s.listen(1) # 监听给定的地址while True:c, addr = s.accept() # 等待下一个连接print(‘got connectio...

2019-03-13 15:26:52 133

原创 python14day

-- coding=utf-8 --文件test_1 = open(‘alice.txt’, ‘a’)test_1.write(“hello 123”)test_1.write("\nword")test_1.close()test_1 = open(r’alice.txt’)test_1.read()print(test_1.read(3))yield生成器def foo()...

2019-03-13 15:26:36 181

原创 python13_1day正则表达式

re正则表达式通配符.对特殊字符进行转义\字符集[a-z]匹配其中的任意字符,[^a]匹配除a以外的其它字母选择符和自模式管道符号(|),匹配’python|perl’‘p(ython|erl)’可选项和重复子模式在子模式后面加上问号,它就变成了可选项r’(http:\)?()*重复0次或多次()+重复1次或多次(){m,n}重复m~n次import rere.compi...

2019-03-13 15:26:23 182

原创 python13day

#############import sys, pprintsys.path.append(‘D:/pycharm_work’)import day_7dir(day_7)import hell4hell4.hello()pprint.pprint(sys.path)#查找模块位置import copyprint(dir(copy))#dir查看模块内容print([n fo...

2019-03-13 15:26:06 127

原创 python12_1day

class TestIterator:value = 0def __next__(self): self.value += 1 if self.value > 10: raise StopIteration return self.valuedef __iter__(self): return selfti = TestIterator()pri...

2019-03-13 15:25:47 178

原创 python12day

私有属性_xclass Rectangle:def init(self):self.width = 0self.height = 0def setSize(self, size): self.width, self.height = size # 使两个值都等于sizedef getSize(self): return self.width, self.height...

2019-03-13 15:25:23 149

原创 python11day

菲波那契数列fibs = [0, 1]num = int(input("how many fibonacci numbers do you want? "))for i in range(num - 2):fibs.append(fibs[-2] + fibs[-1])print(fibs)def init(data):data[‘first’] = {}data[‘middle...

2019-03-13 15:24:45 156

原创 python10_1day

x=input(“x:”)y=input(“y:”)#input假设用户输入的是标准表达式,print(int(x)*int(y))print(pow(2, 3))from math import sqrtimport cmathprint(sqrt(8))print(cmath.sqrt(-1))print(repr(“hello word”)) # 以合法的形式表达值pri...

2019-03-13 15:24:31 197

原创 python10day

def test(num):print(“在函数内部%d对应的地址是%d” % (num, id(num)))result = “hello”print(“函数要返回的内存地址是%d” % id(result))return numa = 10print(“a变量的数据存储地址是%d” % id(a))r = test(a)print("%s的内存地址是 %d" % (r, id®...

2019-03-13 15:24:15 139

翻译 python9_1day

-- coding=UTF-8--import jsonusername = input(“what is your name?”)filename = ‘username.json’with open(filename, ‘w’) as f_obj:json.dump(username, f_obj)print(“we’re rember you,when your back " +...

2019-03-13 15:23:47 202

翻译 数据分析电影

import pandas as pdimport threadingfrom pandas import Seriesimport timestart = time.perf_counter()unames = [‘user_id’, ‘gender’, ‘age’, ‘occupation’, ‘zip’]users = pd.read_table(‘users.dat’, sep...

2019-03-12 19:25:17 538

翻译 python9day分析文本

分析文本title = “Alice in Wordlad”title.split()filename = ‘alice.txt’try:with open(filename) as f_obj:contens = f_obj.read()except FileNotFoundError:msg = “Sorry,the file " + filename + " does not...

2019-03-12 18:22:12 130

翻译 python8day

-- coding=utf-8 --from day_7 import Car,Electricarmy_new_car=Car(‘audi’,‘a4’,2016)print(my_new_car.get_description_name())my_new_car.odometer_reading=23my_new_car.read_odometer()my_tesla=Electr...

2019-03-12 18:14:51 108

翻译 python7day

class Car( ):“”“一次模拟汽车的尝试”""def init(self,make,model,year):#初始化描述汽车的属性self.make =makeself.model = modelself.year = yearself.odometer_reading=0def get_description_name(self):#返回整洁的描述性信息long...

2019-03-12 18:12:49 87

翻译 python6day

def greet_user(username,man):#username是形参print(“hello!”+username+ ’ ‘+man)greet_user(‘yang’,‘n’)#yang是实参def describe_pets(pet_name,animal_type=‘dog’):print("\nl have a "+’ ‘+animal_type+’ ‘+pet_na...

2019-03-12 18:11:38 124

原创 python5day

#continue的用法current_number=0while current_number<10:current_number+=1if current_number %2==0:continueprint(current_number)#在列表之间移动元素unconfirmed_users=[‘alice’,‘brian’,‘candace’]confirmed_u...

2019-03-12 18:09:57 98

原创 python4day

message=’’active =Truewhile active:message=input(“quit”)if message ==‘quit’:active=Falseelse:print(message)while True:city=input(“lanzou”)if city == ‘quit’:breakelse:print(“l would love ...

2019-03-12 18:08:55 68

原创 python3day

#字典alien_0={‘color’:‘green’,‘points’:5}print(alien_0[‘color’])alien_0[‘x_postion’]=0alien_0[‘y_postion’]=25#添加键-值对print(alien_0)alien_1={}alien_1[‘color’]=‘green’alien_1[‘points’]=5print(alie...

2019-03-12 18:07:34 100

原创 python2day

for value in range(1,5):print(value)numbers=list(range(1,6))#生成列表print(numbers)squares=[]for value in range(1,11):square=value2squares.append(square)print(squares)print(min(squares))print(ma...

2019-03-12 18:05:53 69

翻译 python1day

name=“add.cate”print(name.title())#首字母大写print(name.lower())#字母小写print(name.upper())#字母大写first_name=“yang”last_name=“guang peng”full_name=first_name+" “+last_name#+连接print(full_name)print(”\tpy...

2019-03-12 18:02:44 97

空空如也

空空如也

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

TA关注的人

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