如何从Python中读取.txt文件并从中获取特定内容并将其放入元组中?

时间:2016-12-04 16:26:57

标签: python-3.x computer-science

所以我想在Python中读取.txt文件并从文件中获取特定字符串并将它们排列在元组中。到目前为止我的代码是:

opened_file = open(name_of_file, 'r')
file_list = []
candidate_dictionary = {'Donald Trump':'1st', 'Hillary Clinton':'2nd'}
for line in opened_file:
    file_list.append(line)

它显然尚未完成,这就是为什么我被卡住了。

0 个答案:

没有答案