💾 Archived View for squid.flounder.online › cheatsheet › programming › python.gmi captured on 2024-08-31 at 11:40:52. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
sys
time
os
pandas
import sys arguments = sys.argv
with open('path/to/file','r') as file: file.read() # reads all the file into one string file.readlines() # reads the file into a list of lines file.close() # sometimes it helps to do this
with open('/path/to/file','w') as file: file.write(string) # writes a string into the file file.writelines(list) # writes a list into the file line by line file.close() # sometimes it helps to do this
with open('/path/to/file','a') as file: file.write(string) # same as with writing, same with file.writelines too file.close() # sometimes it helps to do this
os.system('command')