【发布时间】:2022-07-27 00:13:02
【问题描述】:
我是使用 jupyter-lab 的 python 初学者,我正在尝试打开文本文件并希望从文本文件中获取数据。虽然是很简单的代码,但是return很奇怪。
什么问题??????
我的代码:
import os
f=open("C:/Users/dfdfdfd/Desktop/python/list.txt","rt")
lines = f.readlines
lines
----返回-----------------
<function TextIOWrapper.readlines(hint=-1, /)>
【问题讨论】:
-
readlines是一个函数,而不是f的属性。你应该叫它f.readlines() -
试试
f.readlines();您需要调用该方法。
标签: python jupyter-lab