我的第一个问题。 如何从正在读取我的txt文件的函数中获取保存在变量中的数组。 TY。
def reading(a):
read = open(a, "r")
rows = read.readlines()
print(rows)
read.close()
return rows
reading("datoteka.txt")
print(reading)
基本上我把它作为输出: [' prvi red \ n',' 25 \ n',' treci red \ n',' cetvrti red'] [函数读取位于0x02B13B70>
答案 0 :(得分:1)
您没有保存reading("datoteka.txt")
的返回值,而是打印了函数对象reading
。而不是最后两行,你想要:
data = reading("datoteka.txt")
print(data)