
CAUTION
Some files are private or not ready yet, if a link gives you a 404 that's why :)
This is a work in progress, new notes will be added daily
List of note Indexes
๐ PROJECTS๐ ART๐ TECHNOLOGY๐ SCIENCE๐ PHILO-PSYCHO๐ HISTORY๐ HEALTH๐ GAMING๐ KNOWLEDGE
.... |\| .|||. |\/| .|\\. .|.
.\\||/|. .\|..|| .\|..|||...||.....
.| .....||.|\\\\\\ ... |\\\/. .\\. .||
.\\| .|\\|..|\\ .\\\\ .\\|. .\\\\\| |\| |\\|
|\\ |\\|.. /\\\. |\|\\ \\\\|. .|\\. .\\\\|
.\\. |\\\\\\\|.. .\\| .\\||\\/|. |\\| .|/\|
\. .\\\||/\|.... \\| |\/ |\\\ |\\\| .\\| \\| ....
|\/ |\\| |\\\\\\\| |\|.\\\ \\\\. |\\\\| |\\ \\. ||..
..|||\| .. .\\\\. |\\\\\\ .\\|....|\\\. |\\\\\\ |/. |/
\\\|.. .\\\ |\\. .\\\| \\| |||\\\. ...|\\/||. .\\\
|\| |\/. /\\\\\| .\\\\. \\. .../|. .|\\\|. |\\\| |\\
. |||\\|. ..||| .\\|. |\| \\|..../\\| |\\| .\\\\\ ..
\\| .||\|.|.. |\\\|./\ \\||\. ||... .\\\\/. |\/||
..|/||. |\\\\\|. .|/\| ||. .||\\\ .|||. |\
.\/| \\\. .|\\\|||\\\||.. .|\\\\\\\|\\\\. /\\\\||. |
.|| |\\\\| .......|\\\\\\. .\\\. ..|||.... .\\\\|.. ...
\\||....|\\\\\\\\||\\\\\\\/ |\|....|||\\\\\\\/....|\\\|
||.|\||\\| .....|\\\\..\\| .|\\\. ||........ .|\|...
. |\ /\\/\\\\\\. |\. .\\\\\\. ./\\\\/ |\\\||.
.|\.|\| .|\|... .. ./\\|..|\\| ..
.|\\| .\\\\.\\\\\\\ \||...\\\|..|\\\|.||
|\. ..||....|| ... ..||\\\. .|.
... .......
โ Python
Python - Read and Write Files
[!WARNING] Remember to close a file after opening it or use
with(see bellow)
file = open("file_name.ext", mode)
file.close()
There are four modes for opening a file:
r: Read - default, open a file for reading, error if it does not existw: Write - overwrites a file if it exists if not creates ita: Append - appends at the end of the file without overwriting it, creates it if does not existx: Create - create a file, error if it already exists
You can also specify if the file should be handle as binary or text (default) using b or t
file = open("file_name.ext", "rt")
file.close()
Read entirely a file
file = open("my_file.md")
content = file.read()
file.close()
Read line by line with a loop
file = open("my_file.md")
for line in file:
print(line, end=" ") # end=" " avoid doubles line breaks
file.close()
Read a limited number of characters
file = open("my_file.md")
content = file.read(20)
file.close()
Read multiple lines
file = open("my_file.md")
content = file.readlines() # returns a list of lines
for line in content:
print(line.strip()) # strip() to remove spaces and line breaks
file.close()
Write in a file
write(): writes a string in a filewritelines(): writes using a list of string (one per line) in a file
# Write
file = open("my_file.md", "w")
file.write("Hello world!\n")
file.write("Second line")
file.write("Third line\nFourth line")
file.write("""Block of text
New line
Tabulation
""")
# Write lines
lines = ["First line\n", "Second line"]
file.writelines(lines)
file.close()
# Append
file = open("my_file.md", "a")
file.write("New line at the end of the file\n")
file.close()
Good practice: use with
Using with allows automatic file opening and closing, even if an error is raised.
with open("my_file.md") as file:
content = file.read()