每次运行 python 脚本时,我想读取位于存储库中的 csv 文件。我已经搜索了克隆 git 并查找和读取特定文件的方法,但没有成功。我看到一个文件,他们刚刚写道:
!git clone ~the link of the repo~
在代码的第一行而不导入任何内容。
我是一个绝对的初学者,我很可能不明白给我的指示。
假设存储库是公共的。
import requests
url = "path/to/raw/file.csv"
resp = requests.get(url)
with open("myfile.csv", "w") as f:
f.write(resp.text)
你能解释一下代码吗,我的意思是像 doe “f” 做什么?