from tensorflow.models.rnn.ptb import reader import tensorflow as tf import numpy as np DATA_PATH = "data/" train_data,valid_data,test_data,_ = reader.ptb_raw_data(DATA_PATH) A = [[1,2,3,4],[2,3,4,5]] for index,item in enumerate(A): print (index,item)
结果
F:\Users\zhangzhen\Anaconda3\python.exe F:/Users/zhangzhen/PycharmProjects/人机大战/MNIST/scope.py 0 [1, 2, 3, 4] 1 [2, 3, 4, 5]
很显然的可以看到, enumerate的含义是取出每一个元素。