import requests
import json
import pygame
import os
import pandas as pd
import re
from PIL import Image, ImageDraw, ImageFont
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)#忽略证书警告
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0',}
url = "https://api.zhihu.com/topstory/hot-list?limit=10&reverse_order=0"
res = requests.get(url, headers=headers, verify=False)
res.encoding = 'utf-8'
s = json.loads(res.text)
列表=[]
list = s['data']
for i in list:
title = i['target']['title']
列表.append(title)
def 加序号(line):
列表 = []
for i in range(len(line)):
dd="%s.%s" % (i + 1, line+"\n")
列表.append(dd)
return 列表
output_str="".join(加序号(列表))
print(output_str)
pygame 2.0.1 (SDL 2.0.14, Python 3.7.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "E:\py_files\Web\Zhihu\zhihu_hot_pic.py", line 26, in <module>
output_str="".join(加序号(列表))
File "E:\py_files\Web\Zhihu\zhihu_hot_pic.py", line 23, in 加序号
dd="%s.%s" % (i + 1, line+"\n")
TypeError: can only concatenate list (not "str") to list
[Finished in 11.1s]