Table of Contents
Several functions for creating, reading, updating, and deleting files
"r" - Read - Default value. Opens a file for reading, error if the file does not exist
"a" - Append - Opens a file for appending, creates the file if it does not exist
"w" - Write - Opens a file for writing, creates the file if it does not exist
"x" - Create - Creates the specified file, returns an error if the file exists
"t" - Text - Default value. Text mode
"b" - Binary - Binary mode (e.g. images)
demo.txt
Hello, Im a demo txt file.
this is the second line of this file.
Good bye~
open file and read
# _file = open("<file's location>", "<mode>")
# _print(_file.read(<the num of characters you want to get>))
_file = open("demo.txt", "r")
print(_file.read())
readline
# print(_file.readline())
_file = open("demo.txt", "r")
print(_file.readline())
file close
# _file.close()
_file = open("demo.txt", "r")
print(_file.readline())
_file.close()
write/ overwrite file
# f.write("<contents>", "<mode>")
f = open("demofile2.txt", "a")
f.write("Now the file has more content!")
f.close()
# f = open("demofile2.txt", "r")
# print(f.read())
# f = open("<>")
f = open("myfile.txt", "x")
總召:許宸珮
Sep 30, 2024:::info ::: What's Git? Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Reference Sheet Expert from NESI
Nov 14, 2023:::info Table of Contents 專案連結: Github ::: 競程熱門題目
May 8, 2023W1-Git 版本控制系統 git 一套免費、開源、且有許多人使用的版本控制軟體 可以在許多以git為技術和新的平台上與人交流,找到開源專案,觀摩他人的程式碼,加入他人的專案協作 版本控制系統version control system 記錄各版本差異 為軟體追加新功能時,會在許多檔案的不同地方修改程式碼,當所有都完成實在是有意義的版本差異,而在版本控制系統中稱呼更動為commit,代表更動中提交的程式碼針對開發中專案,版本記錄系統會追蹤每次commit的程式碼差異、修改者、修改時間、修改原因以行作為單位 切換版本 當新版程式具有錯誤,可快速還原舊版本,稱為回滾(rollback)
Feb 10, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up