2019-10-30

阿里云双11来了!从本博客参与阿里云,服务器最低只要86元/年!

Class Requirement NO.1

(1) %DETAILS OF DOWNLOAD PICTURES% :

import requests
url=’http://dingyue.nosdn.127.net/RHsOiD5X3zH5G74EuyN2ZX8LiNkH6nBg1Mv799nnESWDn1543393877783.jpeg’
response=requests.get(url)
img_info=response.content
print(img_info)
with open(‘universe.png’,’wb’)as f:
f.write(img_info)

(2) %DETAILS OF PAINTING PIE CHART% :

from random import randint
from matplotlib import pyplot as plt
plt.rcParams[“font.sans-serif”] = [‘SimHei’]
plt.rcParams[‘axes.unicode_minus’] = False
x=[randint(100,1000)for i in range (7)]
colors=[‘red’,’blue’,’black’,’green’,’orange’,’pink’,’purple’]
lables=[‘poroportion{}’.format(i)for i in range(1,8)]
explode=[0,0,0,0,0,0,0.6]
plt.pie(x=x,
lables=lables,
colors=colors,
shadow=True,
startangle=80,
explode=explode,
autopct=’%1.1f%%’)
plt.axis(‘equal’)
plt.legend(loc=1)
plt.title(‘world population’)
plt.show()

(3) %KNOWLEDGE ABOUT LIST& :

li=[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,1,2,3,4,5,6]
print(li[])

if “li” is single given, all the members in the list will be shown;

if “li” ends with a bracket (that is “li[]” ),then the single selected #member will be #printed. And what will should be put more #emphsis on is the ‘index’ problem.

li[3]=’python’
print(li)

that is what people usually want to change one or several elements in the list, we only #give one example here to illustrate it.

li.append(‘java’)
print(li)

this is used when we want to add one or more elements to the list

del li[2]
print(li)

this is the basic format of deleting, if you would like to erase all the contents, use #li.clear() will be more convinent

a=[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,1,2,3,4,5,6]
print(type(a))

this is the show of tuple, in fact the ‘type()’ is another kind of function.

in conclusion, what is first and foremost is that we must not forget the ‘print()’ and the #comma above the letters or words in the list, while it seems to be not essential to #treat numbers like this method.

(4) %THE USE OF DICTIONARY% :

information={‘name’:’albert’,
‘height’:187,
‘sex’:’male’,
‘age’:18}
print(information)
print(information[‘name’])

dictionary is easy for us to search information, the former one will just print total #information. By contrast, the latter one can operate as a dictionary can do.

other operations are very similiar to the list , please turn to that part to make a #reference. We will tell more about it in tne following passages.

https://www.jianshu.com/p/aa9cf8cc94eb

Python量化投资网携手4326手游为资深游戏玩家推荐:《梦想协奏曲!少女乐团派对!下载

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
0 条回复 A 作者 M 管理员
    所有的伟大,都源于一个勇敢的开始!
欢迎您,新朋友,感谢参与互动!欢迎您 {{author}},您在本站有{{commentsCount}}条评论