python - Getting pointer instead of string -



python - Getting pointer instead of string -

in script, have following:

file = '%s/data.txt' % (thedirectory) text = open(file) thestring = text.read print 'hello, %s' % (thestring)

it returns this:

hello, <built-in method read of file object @ 0x100534a48>

what's causing this?

you need call method using parentheses:

thestring = text.read()

without parentheses, python assigns reference method thestring (which isn't string @ all, @ point).

python file pointers filesystems

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -