본문 바로가기

Python24

20. File I/O in Python 1. File Open 파이썬에서 파일을 열려면 open() 함수를 사용합니다. open() 함수는 두 가지 인수를 받습니다. 2. File Write There are two watys to write coontent to a file write(): Writing a string to the file writelines(): Writehs a list of strings to the file 3. Using the With statement Python's with statement allows user to open a file, perform operations on it, and automatically close the file afterwards 4. File Read There are se.. 2024. 3. 20.
19. Python Module 1. Module To create a module in Python, simply write your code in a file with the .py extension. Modules can contain not only functions but also variables, classes, and more. You can import them into other scripts using the import statement. 2. How to use modules using Google Drive 2024. 3. 20.
18. Python Error Handling 1. Exception An exception is an unexpected problem or error that can occur during program execution. When an exception occurs, the program is interrupted. Therefore, it is important to handle exceptions appropriately to prevent program interruption and provide error information to the user. 2. Basic Structure of Exception Handling User can handle all exceptions without specifying an error code a.. 2024. 3. 19.
17. Special Method 1. Special Methods Special methods, also known as magic methods in Python, are methods that have names starting and ending with double underscores (__). These methods are automatically called by the Python interpreter when certain operators or built-in functions are used. init : This method is called when an object is created. It is used to initialize the object's attributes. str : This method i.. 2024. 3. 19.