Can I redirect the stdout in python into some sort of string buffer?

前端 未结 9 1674
野趣味
野趣味 2020-11-22 06:23

I\'m using python\'s ftplib to write a small FTP client, but some of the functions in the package don\'t return string output, but print to stdout.

9条回答
  •  深忆病人
    2020-11-22 06:48

    Use pipe() and write to the appropriate file descriptor.

    https://docs.python.org/library/os.html#file-descriptor-operations

提交回复
热议问题