# 操作思路: # 1.打开指定的TXT # 2.读取TXT中的内容 # 3.处理数据 # 4.将内容存放在数组中 # 5.打印数组中的数据 def print_hi(name): print(f'Hi, {name}') with open('TNS.txt', 'r') as file: datas = file.readlines() print(datas) # print(datas[0].strip()) list = [] for data in datas: data = data.strip() print(data) list.append(data) print(list) if __name__ == '__main__': print_hi('PyCharm,我要读取TXT中内容放到列表中')
标签:__,读取,16,print,TXT,data,datas From: https://www.cnblogs.com/mxx520/p/16948246.html