SlideShare a Scribd company logo
FILE HANDLING
FILES IN PYTHON
Python provides several built-in functions and methods for creating, opening, reading,
writing, and closing files.
FILE OPENING AND MODES
Syntax:
file = open("filename", "mode“)
Examples:
file = open("example.txt", "r")
file = open("example.txt", "w")
file = open("example.txt", "a")
file = open("example.txt", "rb")
FILE OPENING MODES
Modes Description
r Read Mode
w Write Mode
a Append Mode
t Text Mode
b Binary Mode
+ Concatenation (ab+,a+,w+,wb+)
x Opens- for exclusive creation.

More Related Content

PDF
PremierePro_CC_2014_Tutorial_in detail.pdf
PPTX
Presentation_Science_about current scenario.pptx
PPTX
RK_Presentation_Science_current technology.pptx
PPTX
JAVA_BEAN.pptx
PPT
6.Preventive Maintenance and Troubleshooting.ppt
PPT
LDC Seminar Hardware.ppt
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
PremierePro_CC_2014_Tutorial_in detail.pdf
Presentation_Science_about current scenario.pptx
RK_Presentation_Science_current technology.pptx
JAVA_BEAN.pptx
6.Preventive Maintenance and Troubleshooting.ppt
LDC Seminar Hardware.ppt
2024 Trend Updates: What Really Works In SEO & Content Marketing
Storytelling For The Web: Integrate Storytelling in your Design Process

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Encapsulation theory and applications.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
August Patch Tuesday
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
Univ-Connecticut-ChatGPT-Presentaion.pdf
Unlocking AI with Model Context Protocol (MCP)
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Group 1 Presentation -Planning and Decision Making .pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Tartificialntelligence_presentation.pptx
1. Introduction to Computer Programming.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
WOOl fibre morphology and structure.pdf for textiles
Encapsulation theory and applications.pdf
A comparative analysis of optical character recognition models for extracting...
August Patch Tuesday
NewMind AI Weekly Chronicles - August'25-Week II
Zenith AI: Advanced Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
SOPHOS-XG Firewall Administrator PPT.pptx
TLE Review Electricity (Electricity).pptx
Programs and apps: productivity, graphics, security and other tools
Ad
Ad

Python_Filehandling_basic for beginners.pptx

  • 2. FILES IN PYTHON Python provides several built-in functions and methods for creating, opening, reading, writing, and closing files.
  • 3. FILE OPENING AND MODES Syntax: file = open("filename", "mode“) Examples: file = open("example.txt", "r") file = open("example.txt", "w") file = open("example.txt", "a") file = open("example.txt", "rb")
  • 4. FILE OPENING MODES Modes Description r Read Mode w Write Mode a Append Mode t Text Mode b Binary Mode + Concatenation (ab+,a+,w+,wb+) x Opens- for exclusive creation.