|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {
- "pycharm": {
- "name": "#%% md\n"
- },
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "\n",
- "Gegeben ist eine binäre Grafikdatei <code>ohm.png</code>."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "pycharm": {
- "name": "#%%\n"
- }
- },
- "outputs": [],
- "source": [
- "from IPython.display import Image\n",
- "Image(filename=\"ohm.png\")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {
- "pycharm": {
- "name": "#%% md\n"
- },
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "source": [
- "_Aufgabe 1_\n",
- "\n",
- "Erstellen Sie ein Python-Programm, dass diese Datei in eine zweite\n",
- "Datei <code>logo.png</code> kopiert. Übertragen Sie die Daten bitte\n",
- "in 32 Byte Paketen."
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "pycharm": {
- "name": "#%%\n"
- },
- "slideshow": {
- "slide_type": "slide"
- }
- },
- "outputs": [],
- "source": [
- "from IPython.display import Image\n",
- "\n",
- "\n",
- "with open(\"ohm.png\", \"rb\") as source_file:\n",
- " with open(\"logo.png\", \"wb\") as dest_file:\n",
- " buffer_size = 32\n",
- " buffer = source_file.read(buffer_size)\n",
- " while len(buffer)>0:\n",
- " dest_file.write(buffer)\n",
- " buffer = source_file.read(buffer_size)\n",
- "\n",
- "\n",
- "Image(filename=\"logo.png\")"
- ]
- }
- ],
- "metadata": {
- "celltoolbar": "Slideshow",
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "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.9.9"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 1
- }
|