import string
######## 1 ###############else chr(ord(‘a’)+1-ord(‘z’)+ord(x))
s = “http://www.pythonchallenge.com/pc/def/map.html”
l1 = [chr(ord(x)+2)for x in s if ord(‘a’)<=ord(x) <=ord(‘z’)]
s2 = ‘’.join(l1)
l2 = [chr(ord(x)-26) if x ==’|’ or x == ‘{’ else x for x in s2 ]
s3 = ‘’.join(l2)
print(s3)
############### 4 #################
import requests
import re
ans = “12345”
# key = [‘44827’]
number = re.compile("\d+")
n = 1
while n<401:
r = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ans)
t = r.text
key = re.findall(number, str(t)) # 返回值为列表
if len(key) == 2:
print(t)
temp_text1 = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ‘’.join(key[1])).text
temp_num1 = re.findall(number, str(temp_text1))
if temp_num1:
ans = ‘’.join(temp_num1)
print(ans)
else:
temp_text2 = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ‘’.join(key[1])).text
temp_num2 = re.findall(number, str(temp_text2))
ans = ‘’.join(temp_num2)
print(ans)
elif key:
ans = ‘’.join(key)
print(ans)
else:
print(t)
ans = str(int(ans)/2)
# break
n = n+1
################## 5 ######################
import requests
import re
import pickle
# r = requests.get(“http://www.pythonchallenge.com/pc/def/banner.p”)
# t = r.text
original = “D:\Desktop\python学习\新建文本文档.txt”
destination = “D:\Desktop\python学习\新建文本文档2.txt”
content = ‘’
outsize = 0
with open(original, ‘rb’) as infile:
content = infile.read()
with open(destination, ‘wb’) as output:
for line in content.splitlines():
outsize += len(line) + 1
output.write(line + str.encode(’\n’))
# print(“Done. Saved %s bytes.” % (len(content)-outsize))
f2 = open(‘D:\Desktop\python学习\新建文本文档2.txt’,‘rb’)
l = pickle.load(f2) # 一个列表
print(l)
for t in l:
ans = ‘’
for i in t:
ans = ans + i[0]*i[1]
print(ans)
################### 6 #########################
import requests
import re