名为data
的目录中将有多个txt
文件。但我只想read
有date of that day as the name
的文件。我该怎么做?。
我的代码:
import time
from requests import get
url = "https://zonefiles.io/a/yourApiKey/update/1/"
def domains_ind_day():
with open('../data/{}.txt'.format(time.strftime('%d-%m-%Y', time.gmtime())), 'wb') as file:
response = get(url)
file.write(response.content)
试试这个:
filename = '../data/' + format(time.strftime('%d-%m-%Y', time.gmtime()) + '.txt'
with open(filename, 'wb') as file: