From df203fe135a50ea0a78b6ad2760ee46b0bc28b38 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Mon, 4 Apr 2022 14:01:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main/views.py b/app/main/views.py index a475110..013b73a 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -41,9 +41,8 @@ def api_v1(name: str): abort(500) if 7 <= length <= 10: data = db().fetch(name) + # 使用设置的长度减去已有数据的长度, 将结果转换为string类型, 再和数据库内的数据进行拼接 number = '0' * (length - len(str(data[-1]))) + str(data[-1]) - # 将设置的长度减去数据库内已有的数据库字符串长度剩下的结果为[0]的个数 - # 再将这个字符串后拼接上数据库内已有次数的字符串, 就可以得到最终的结果 response = make_response(view(theme, int(length), name, number)) response.headers['Content-Type'] = 'image/svg+xml; charset=utf-8' response.headers['cache-control'] = 'max-age=0, no-cache, no-store, must-revalidate'