码迷,mamicode.com
首页 > 其他好文 > 详细

将.txt文件中的内容放入列表中

时间:2019-03-02 16:05:15      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:info   image   alt   mic   图片   print   文件   pytho   readline   

.txt文件如下:

技术图片

代码实现:

with open(F:/F/python_code/00.txt) as f:
    a = f.readlines()

b = [n[:-1] for n in a]
print(b)

技术图片

将.txt文件中的内容放入列表中

标签:info   image   alt   mic   图片   print   文件   pytho   readline   

原文地址:https://www.cnblogs.com/czz0508/p/10461405.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!