# coding:utf-8
import json
#1
base_url='http://www.python.com/?page={}'
print(base_url.format('1'))
#2.1
list_a = range(1, 10)
#2.2
for num in list_a:
print(num)
#2.3
for num in list_a:
req_url = base_url.format(num)
print(req_url)
#3.1
a = 'I like python'
#3.2
b = a.split(' ')
#3.3
for strs in b:
print(strs)
#3.3
for num2 in range(0,len(b)):
print(num2, b[num2])
#4.1
c = b[1]
print(c)
#4.2
d = b[2][2:4]
print(d)
#4.3
e = b[2]
nPos = e.find(d)
if nPos>=0:
print('存在')
else:
print('不存在')
#5.1
if e.startswith(d):
print('是')
else:
print('不是')
#5.2
for num in list_a:
if num<6:
print(num,'<6')
else:
print(num,'>=6')
#5.3
for num in list_a:
if num==6:
continue
print(num)
#5.4
for num in list_a:
if num>6:
break
print(num)
#6.1
dict_a = {}
print(type(dict_a))
#6.2
for num in range(0,len(list_a)):
dict_a[num] = list_a[num]
print(dict_a)
#6.3
for a in dict_a:
print(a,dict_a[a])
#6.4
encode_json = json.dumps(dict_a)
print(type(encode_json), encode_json)
#7.1
for num in range(1,10):
for snum in range(1,num+1):
res = num * snum
print(str(num)+"*"+str(snum)+"="+str(res),end=' ')
print()
【Python爬虫】-第四期课后练习7
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...