Created
November 12, 2022 09:23
-
-
Save mertcangokgoz/020e8834d616b9868ec9053f64fc6bc6 to your computer and use it in GitHub Desktop.
Center Terminal Output
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 os | |
def center_terminal_output(var: str, space: int = None) -> str: | |
if not space: | |
space = (os.get_terminal_size().columns - len(var.splitlines()[len(var.splitlines()) // 2])) / 2 | |
return "\n".join(" " * space + var for var in var.splitlines()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
вернуть телефон в исходным кодом