所以我有一个这样的功能:
def get_hour_from_line(line_string):
# This function takes the line as a string for input and
# returns the hour as an integer
infile = open(line_string,"r")
data = infile.read()
new_lst = data.split(",")
for i in new_lst:
data = i.split()
print(data)
我得到的输出是:
['NULL', '9/12/14', '22:50']
['6763'] #continues down for a long time
我需要为第一个列表中的第二个项目分配一个变量hours。但是,如果我索引[-1]或[2:3]我仍然最终[ ' 6763']或[]。有没有办法删除第二个列表或迭代它??