跳转至

Python

cheetsheet

1
2
3
4
5
# 获取当前时间
now = datetime.datetime.now()

# 获取 15 分钟前的时间
datetime.datetime.now() - datetime.timedelta(minutes = 15)

下载 google fonts

import requests

with open("example.css", "r") as f:
    text = f.read()
    urls = re.findall(r'(https?://[^\)]+)', text)

for url in urls:
    filename = url.split("/")[-1]
    r = requests.get(url)
    with open("./fonts/" + filename, "wb") as f: 
        f.write(r.content)
    text = text.replace(url, "/fonts/" + filename)

with open("example.css", "w") as f:
        f.write(text)
作者: aisuhua