简体   繁体   中英

how to take file like object in a file in python

filename = fileobject.read()

我想在文件中传输/分配对象的全部数据。

You are almost doing it correctly already; the code should read

filecontent = fileobject.read()

read() with no arguments will read the whole data, ie the whole file content. The file name has nothing to do with that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM