如果我们发现在某平台发现这代码文件挺有用的,可以通过Python代码将其下载。
代码如下:
import requests
from pathlib import Path
if Path("example.py").is_file():
print("example.py has already been exists, not downloading")
else:
print("Downloading example.py file")
request = requests.get("文件的网址,并且网址最后面得有文件后缀标志")
with open("example.py", "wb") as f:
f.write(request.content)
就可以看到在文件夹里已经将example.py文件下载下来了。
给个赞再走呗~