I use the following code segment to read a file in python:
(我使用以下代码段在python中读取文件:)
with open ("data.txt", "r") as myfile:
data=myfile.readlines()
Input file is:
(输入文件为:)
LLKKKKKKKKMMMMMMMMNNNNNNNNNNNNN
GGGGGGGGGHHHHHHHHHHHHHHHHHHHHEEEEEEEE
and when I print data I get
(当我打印数据时)
['LLKKKKKKKKMMMMMMMMNNNNNNNNNNNNN
', 'GGGGGGGGGHHHHHHHHHHHHHHHHHHHHEEEEEEEE']
As I see data is in list
form.
(如我所见,数据是list
形式的。)
How do I make it string? (我如何使其成为字符串?)
And also how do I remove the "\n"
, "["
, and "]"
characters from it? (还有如何从中删除"\n"
, "["
和"]"
字符?)
ask by klijo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…