Skip to Main Content
Python Rusz głową! Wydanie II
book

Python Rusz głową! Wydanie II

by Paul Barry
November 2017
Intermediate to advanced content levelIntermediate to advanced
578 pages
23h 17m
Polish
Helion
Content preview from Python Rusz głową! Wydanie II
jesteś tutaj
457
Obsługa wyjątków
try:
with open(‘myfile.txt’) as fh:
file_data = fh.read()
print(file_data)
except FileNotFoundError:
print(‘Brak pliku z danymi.’)
except PermissionError:
print(‘Brak wymaganych uprawnień.’)
except Exception as err:
print(‘Wystąpił jakiś inny błąd:’, str(err))
To jest zawartość pliku
try_example.py.
import mysql.connector
class ConnectionError(Exception):
pass
class CredentialsError(Exception):
pass
class SQLError(Exception):
pass
class UseDatabase:
def __init__(self, config: dict) -> None:
self.configuration = config
def __enter__(self) -> ‘cursor’:
try:
self.conn = mysql.connector.connect(**self.configuration) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python. Receptury. Wydanie III

Python. Receptury. Wydanie III

David Beazley, Brian K. Jones
Python. Programuj szybko i wydajnie

Python. Programuj szybko i wydajnie

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9788328337343