第三天作业

#    print(list1)
list1 = str2.split(':')
print(list1)
# lower&upper 大小写
str3 = 'aabbCC'
#把str3的字母都变成小写
lower_str3 = str3.lower()
print(lower_str3)
#把str3都变成大写
upper_str3 = str3.upper()
print(upper_str3)
# startswith&endswith 判断字符的开头或结尾是否是什么
str4 = '飞龙是个靓仔'
print(str4.startswith('飞龙'))
print(str4.startswith('翱博'))
print(str4.endswith('靓仔'))
print(str4.endswith('sb'))
#replace:替换.replace(旧,新)
str5 = '刘德华说飞龙很帅'
str5 =str5.replace('飞龙','翱博')
print(str5)
#i是digit:判断字符是否是数字
str6 = '15201314'
print(str6.isdigit())
list2 = ['飞龙',18,'飞龙']
# append
list2.append('female')
print(list2)
# count:计算列表中值的数量
print(list2.count('飞龙'))

import requests
#requests.get('数据连接')
response = requests.get('

https://gss1.bdstatic.com/9vo3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=4c9bf08f04f41bd5da53eff269e1e6f6/d439b6003af33a87d8d517becc5c10385243b5dd.jpg')
#content就是获取图片的二进制流数据
print(response.content)
#保存数据
# 读取二进制流数据 write + bytes wb
with open('cang老师.jpg','wb') as f:
#f.write(传入二进制流的数据)
 f.write(response.content)
posted on 2019-09-26 00:10  茂阴天才  阅读(96)  评论(0)    收藏  举报