Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
from pathlib import Path p = Path("sample.txt") p.write_text("Line 1 Line 2 Line 3", encoding="utf-8") print("Exists:", p.exists()) print("Size:", p.stat().st_size, "bytes") print("Stem:", p.stem) print("Suffix:", p.suffix) content = p.read_text(encoding="utf-8") print("Lines:", len(content.splitlines())) p.unlink()
Result
Open