Python中的基本操作

sys

import sys
program_name = sys.argv[0]
arguments = sys.argv[1:]
paths = sys.path # return lib paths

os

import os
os.system() # Execute a shell command
os.getcwd() # Returns the current working directory.
os.getgid() # Return the real group id of the current process.
os.getuid() # Return the current process’s user id.
os.getpid() # Returns the real process ID of the current process.
os.uname() # Return information identifying the current operating system.
os.chroot(path) # Change the root directory of the current process to path.
os.listdir(path) # Return a list of the entries in the directory given by path.
os.mkdir(path) # Create a directory named path with numeric mode mode.
os.makedirs(path) # Recursive directory creation function.
os.remove(path) # Remove (delete) the file path.
os.removedirs(path) # Remove directories recursively.
os.rename(src, dst) # Rename the file or directory src to dst.
os.rmdir(path) # Remove (delete) the directory path.

os.path

import os.path
os.path.isfile('my_settings.dat')
os.path.isdir('src')
os.path.exists('tumblr')

string

import string
string.ascii_lowercase # 'abcdefghijklmnopqrstuvwxyz'

Python

这篇文章: 有用 无用
创建 2018-08-06 02:11:35 / 更新 2018-10-16 05:54:42