在kaggle上創建kernel,加入如下代碼。
連續運行兩次,可以看到保存的文件名字不一樣,且無論運行錯少次,都只有一個輸出文件。
這說明,kaggle上的kernel每次commit運行,都會清空輸出文件。
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load in import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) df = pd.DataFrame({'name': ['Raphael', 'Donatello'], 'mask': ['red', 'purple' ], 'weapon': ['sai', 'bo staff' ]}) df.to_csv(index=False) import time def get_now_time_string(): return time.strftime("%Y%m%d_%H%M%S",time.localtime()) file_name = get_now_time_string() + '.csv' df.to_csv(file_name) print(file_name, 'saved.')
