Python Forum
How to "tee" (=split) output to screen and into file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to "tee" (=split) output to screen and into file?
#2
I don't know that you can do that with a single command, but I would do this:

with open("file_name", mode='w', encoding='UTF8') as output:
    something = "This is what you want to write"
    print(something)
    print(something, file=output)
Sig:
>>> import this

The UNIX philosophy: "Do one thing, and do it well."

"The danger of computers becoming like humans is not as great as the danger of humans becoming like computers." :~ Konrad Zuse

"Everything should be made as simple as possible, but not simpler." :~ Albert Einstein
Reply


Messages In This Thread
RE: How to "tee" (=split) output to screen and into file? - by rob101 - Jun-23-2023, 07:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Why is there an output of None akbarza 1 546 Nov-27-2023, 02:53 PM
Last Post: deanhystad
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,203 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Split pdf in pypdf based upon file regex standenman 1 2,228 Feb-03-2023, 12:01 PM
Last Post: SpongeB0B
  How to split file by same values from column from imported CSV file? Paqqno 5 2,934 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  [split] Results of this program in an excel file eisamabodian 1 1,646 Feb-11-2022, 03:18 PM
Last Post: snippsat
  split txt file data on the first column value shantanu97 2 2,526 Dec-29-2021, 05:03 PM
Last Post: DeaD_EyE
  [split] Help- converting file with pyton script eltomassito 6 3,384 Jul-02-2021, 05:29 PM
Last Post: snippsat
  How do I split the output? AnunnakiKungFu 2 1,841 Feb-25-2021, 11:13 PM
Last Post: AnunnakiKungFu
  Split Characters As Lines in File quest_ 3 2,606 Dec-28-2020, 09:31 AM
Last Post: quest_
  [split] How to convert the CSV text file into a txt file Pinto94 5 3,479 Dec-23-2020, 08:04 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020