我試圖從2012年和11月份開始,一直到當前年份和月份,一直循環使用幾個月的列表。單擊幾個月的月份檢查文件是否存在
start_year = "2012"
start_month = "November"
month = start_month
year = start_year
# some sort of for loop or cycle here
try:
with open('{} {}.csv'.format(month, year)):
CSVFile = True
if CSVFile:
print "do something cool here"
except IOError:
CSVFile = False
print ""
任何意見或建設性的意見,如何實現這個或建議將不勝感激。 感謝SMNALLY
'curr',也許? – inspectorG4dget
@ inspectorG4dget我愛讀你的轉換,讓我笑:P – Ryflex
@Hyflex:睡眠剝奪了我爲一個非常熱鬧的派對嘉賓(微調微調wink wink) – inspectorG4dget