本文共 293 字,大约阅读时间需要 1 分钟。
题目:Using the file school_prompt.txt, assign the third word of every line to a list called three
school_prompt = open('school_prompt.txt','r')chars = school_prompt.readlines()three = list()for word in chars: word = word.split() # 重点,要把字符串转化为列表,不然输出的只是单字母 three.append(word[2])print(three)
转载地址:http://rnrci.baihongyu.com/