Skip to main content

printsection

print("\n", "실습 결과".center(50, "-"), end="\n\n") 를 한 줄로. 출력 결과를 구간별로 나눠 보기 좋게 구분해 줍니다.

pip install printsection
# uv 사용 시: uv add printsection
from printsection import print_section

print_section("실습 1")
print("...")
print_section("실습 2")

----------------------실습 1----------------------

...

----------------------실습 2----------------------

위아래 빈 줄과 가운데 정렬이 기본입니다. 한글처럼 화면에서 2칸을 차지하는 글자도 폭을 계산해서 실제 화면 기준으로 가운데에 맞춥니다.

옵션

호출할 때 원하는 값만 바꾸면 됩니다.

print_section("실습 결과", width=60, fillchar="=")
print_section("왼쪽 정렬", align="left")          # "center" / "left" / "right"
print_section("빈 줄 조절", top=2, bottom=0)
print_section("str.center처럼", wide=False)       # 글자 수 기준으로 계산
print_section()                                   # 글자 없이 구분선만
옵션 기본값 설명
width 50 전체 너비
fillchar "-" 채움 문자 (한 글자)
align "center" "center", "left", "right"
top 1 위쪽 빈 줄 수
bottom 1 아래쪽 빈 줄 수
wide True 한글 등 전각 문자를 2칸으로 계산
file sys.stdout 출력 대상

기본값 한 번에 바꾸기

from printsection import print_section, set_defaults, reset_defaults

set_defaults(width=70, fillchar="*")
print_section("1번 문제")
print_section("2번 문제")
reset_defaults()

문자열만 받기

from printsection import format_section

s = format_section("실습 결과")   # 출력하지 않고 문자열 반환

Metadata

Release files for printsection 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for printsection 0.2.0
File Size Uploaded
printsection-0.2.0.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for printsection 0.2.0
File Interpreter ABI Platform
printsection-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / printsection-0.2.0.tar.gz

Download URL printsection-0.2.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a4e03d69d21d7998a533cd23a344a55deaa25b12fa2932d09c55511cb5564981
BLAKE2b-256 checksum
How to use checksums
666b1a36c361bd39e2b9f1b4e6b294a3ab2de7c34201138a10591282d948f429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / printsection-0.2.0-py3-none-any.whl

Download URL printsection-0.2.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c170cfa511de7ae991bbc4b4c5e14f6c8ebba1ab83c1c35fddd3d71d01d21cb
BLAKE2b-256 checksum
How to use checksums
81516741d4024edb55a6b48ff8e5faec7707cf96fbeb1b540e458527df4ac675
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page