python常用库

Method

Path

exists(): to see if this file or directory exists or not

is_file()
is_dir()

path.name: only return the file name
path.stem: return the file name without the extension
path.suffix: get the extension
path.parent: get the parents of this path

path.with_name(): to create a new path object based on this existing pass but only change the name and extension of the file, it don't rename, just

path.absoulte()

zip

import zipfile

csv

import csv	
writer = csv.write()
writer.writerow(["transcation_id", "product_id", "price"])
writer.writerow([1000, 1, 5])
writer.writerow([1001, 2, 15])

json

import json

sqlit

import sqlite3

timestamps: time & datetiem

import time

import datetime

random

import random

browser

import webbrowser

email

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from pathlib import Path
import smtplib 

Template

from string import Template	

sys

import sys

running external programs

import subprocess
posted @ 2022-05-18 13:17  deadright  阅读(2)  评论(0)    收藏  举报