自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 绘制人口地图

import jsonfrom country_codes import get_country_codeimport pygalimport pygal_maps_world.mapsfilename = ‘population_data.json’with open(filename) as f:pop_data = json.load(f)#创建一个包含人口数量的字典cc_population = {}#打印每个国家2010年的人口数量for pop_dict in pop_dat

2020-10-25 15:25:07 1291

原创 复习时的回顾

对类的一些整理:1. *以self为前缀的变量都可供类中的所有方法使用,可以通过类的任何实例来访问这些变量。*2. 类中的每个属性都必须有初始值,即使这个值为0或空字符。对文件的读取:1.方法readlines()从文件中读取每一行,并将其存储在一个列表中。2.打开文件时: ① ‘r’ 读取模式 ② ‘w’ 写入模式 ③ 'a' 附加模式,,将内容附加到文件末尾,而不是覆盖文件原来的美容。 ④ ‘r+’ 能够读取和写入文件 **注意:在②的模式中,如

2020-10-24 15:59:31 100

原创 缺少了choice导致的错误

TypeError: unsupported operand type(s) for +: ‘int’ and ‘list’choice 函数:s = choice([0,1,2,3]) 这里面choice提取的数字属于int类型所以type(s) 是 int 类型s = ([0,1,2,3]) 若省去了choice就是 list类型了由于大意漏掉了choice,导致我在学习随机漫步这个环节中一直都没发现这个错误。...

2020-10-23 21:27:06 173

原创 换行

print(str(results)+’\n’)print(frequence)在输出列表results 和 frequence之间换行输出:[8, 3, 6, 6, 1, 3, 6, 4, 5, 5, 8, 3, 2, 7, 1, 2, 7, 2, 2, 6, 2, 4, 6, 8, 8, 3, 6, 1, 5, 5, 1, 3, 4, 7, 5, 6, 2, 7, 3, 6, 6, 4, 5, 6, 2, 7, 1, 2, 6, 6, 1, 2, 4, 7, 5, 3, 2, 1, 8, 6,

2020-10-23 20:45:04 82

转载 Python可迭代对象中的添加和删除(add,append,pop,remove,insert)的区分

列表listclassmates = [‘Michael’, ‘Bob’, ‘Tracy’]classmates.append(‘Adam’) //添加在末尾,没有add()方法classmates.insert(1, ‘Jack’) //在指定位置添加classmates.pop(1) //在知道位置删除,参数是索引del classmate[1] //删除第二个元素classmates.remove(‘Bob’) //参数是元素,删

2020-10-23 15:49:37 716

原创 AttributeError

4@TOC创建类后来创建对象时,参数签名要与创建类时的顺序一致。不然会报错AttributeError:‘pygame.Surface’ object has no attribute ‘…’参考外星人大战游戏wrer功能快捷键撤销:Ctrl/Command + Z重做:Ctrl/Command + Y加粗:Ctrl/Command + B斜体:Ctrl/Command + I标题:Ctrl/Command + Shift + H无序列表:Ctrl/Command + Shift +

2020-10-23 10:54:13 421

空空如也

空空如也

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

TA关注的人

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