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
Post a Comment