参考文献按照作者首字母自动排序
(2018-06-18 19:46:26)分类: Python |
# coding=utf8
refs = []
f = open('C:\\Users\\lx201\\Desktop\\11.txt', encoding='utf8')
for line in f:
refs.append(line)
refs.sort(key=lambda x:(x[0], x[1]))
count = 0
for i in refs:
count +=1
print('[' + str(count) + ']' + ' ' + i, end='')
原有的参考文献存在11.txt中,结果会print出来。