Created
December 14, 2023 03:34
-
-
Save jiafangtao/4b5f87c0b251b620fe6f3ea1209939cc to your computer and use it in GitHub Desktop.
random output to stdout or stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import random | |
print(f"hello from {sys.argv[0]}") | |
out = 0 | |
err = 0 | |
while out < 10 and err < 10: | |
choice = random.randint(0, 1) | |
if choice > 0: | |
sys.stdout.write(f'out {out}...\n') | |
sys.stdout.flush() | |
out += 1 | |
else: | |
sys.stderr.write(f'err {err}...\n') | |
sys.stderr.flush() | |
err += 1 | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment