{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "54d897cc",
   "metadata": {},
   "source": [
    "# 15-18 · pathlib: read_text, write_text, read_bytes, write_bytes\n",
    "\n",
    "Praktyka do rozdziału [«pathlib: wygodne metody»](/pl/chapters/rozdzial-15/15-18-pathlib-udobnye-metody.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "065db491",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "260b5743",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:53:01.941925Z",
     "iopub.status.busy": "2026-08-18T15:53:01.941820Z",
     "iopub.status.idle": "2026-08-18T15:53:01.965916Z",
     "shell.execute_reply": "2026-08-18T15:53:01.965396Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "привет\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "p = Path(\"nastroyki3.txt\")\n",
    "p.write_text(\"привет\", encoding=\"utf-8\")\n",
    "text_back = p.read_text(encoding=\"utf-8\")\n",
    "print(text_back)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fad97c7",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka aktywności ★ - Dane binarne"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "005be386",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:53:01.966844Z",
     "iopub.status.busy": "2026-08-18T15:53:01.966735Z",
     "iopub.status.idle": "2026-08-18T15:53:01.969379Z",
     "shell.execute_reply": "2026-08-18T15:53:01.968937Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'\\x01\\x02\\x03'\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "pb = Path(\"signal3.bin\")\n",
    "pb.write_bytes(bytes([1, 2, 3]))\n",
    "bytes_back = pb.read_bytes()\n",
    "print(bytes_back)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
