Python 速查表
来源:互联网 发布:客户关系维护软件 编辑:程序博客网 时间:2024/06/06 04:32
Python sys变量
argv
命令行参数
builtin_module_names
链接C模块
byteorder
原生字节排序
check_interval
Signal检查频率
exec_prefix
根目录
executable
可执行文件的名称
exitfunc
退出函数名称
modules
加载的模块
path
搜索路径
platform
当前平台
stdin, stdout, stderr
I / O的文件对象
version_info
Python版本信息
winver
版本号
Python sys.argv
sys.argv[0]
foo.py
sys.argv[1]
bar
sys.argv[2]
-c
sys.argv[3]
qux
sys.argv[4]
--h
sys.argv for the command:$ python foo.py bar -c qux --h
Python os 变量
altsep
替代 sep
curdir
当前 dir 字符串
defpath
默认搜索路径
devnull
空设备的路径
extsep
扩展分隔符
linesep
行分隔符
name
OS的名称
pardir
父目录字符串
pathsep
修补程序分隔符
sep
路径分隔符
注册操作系统名称: "posix", "nt","mac", "os2", "ce", "java", "riscos"
Python类特殊方法
__new__(cls)
__lt__(self, other)
__init__(self, args)
__le__(self, other)
__del__(self)
__gt__(self, other)
__repr__(self)
__ge__(self, other)
__str__(self)
__eq__(self, other)
__cmp__(self, other)
__ne__(self, other)
__index__(self)
__nonzero__(self)
__hash__(self)
__getattr__(self, name)
__getattribute__(self, name)
__setattr__(self, name, attr)
__delattr__(self, name)
__call__(self, args, kwargs)
Python列表方法
append(item)
pop(position)
count(item)
remove(item)
extend(list)
reverse()
index(item)
sort()
insert(position, item)
Python字符串方法
capitalize() *
lstrip()
center(width)
partition(sep)
count(sub, start, end)
replace(old, new)
decode()
rfind(sub, start ,end)
encode()
rindex(sub, start, end)
endswith(sub)
rjust(width)
expandtabs()
rpartition(sep)
find(sub, start, end)
rsplit(sep)
index(sub, start, end)
rstrip()
isalnum() *
split(sep)
isalpha() *
splitlines()
isdigit() *
startswith(sub)
islower() *
strip()
isspace() *
swapcase() *
istitle() *
title() *
isupper() *
translate(table)
join()
upper() *
ljust(width)
zfill(width)
lower() *
标记为*的方法与8-bit字符串的区域设置相关。Python 文件方法
close()
readlines(size)
flush()
seek(offset)
fileno()
tell()
isatty()
truncate(size)
next()
write(string)
read(size)
writelines(list)
readline(size)
Python 索引和切片
len(a)
6
a[0]
0
a[5]
5
a[-1]
5
a[-2]
4
a[1:]
[1,2,3,4,5]
a[:5]
[0,1,2,3,4]
a[:-2]
[0,1,2,3]
a[1:3]
[1,2]
a[1:-1]
[1,2,3,4]
b=a[:]
a浅拷贝
索引和切片 a=[0,1,2,3,4,5]Python日期时间方法
today()
fromordinal(ordinal)
now(timezoneinfo)
combine(date, time)
utcnow()
strptime(date, format)
fromtimestamp(timestamp)
utcfromtimestamp(timestamp)
Python 时间方法
replace()
utcoffset()
isoformat()
dst()
__str__()
tzname()
strftime(format)
Python 日期格式化
%a
输出当前是星期几的英文简写(Sun)
%A
输出完整的星期几名称英文(Sunday)
%b
输出月份的英文简写(Jan)
%B
输出月份的英文完整名称(January)
%c
以本地时间显示日期和时间
%d
显示1-31之间的数,每月的第几天,也就是年月日中的日(01 to 31)
%H
以24小时制显示小时(00 to 23)
%I
以12小时制的方式显示当前小时(01 to 12)
%j
显示当前日期为一年中的第几天(001 to 366)
%m
显示1-12之间的月份 (01 to 12)
%M
显示00-59之间的分钟数 (00 to 59)
%p
以 A.M./P.M.方式显示是上午还是下午
%S
显示0-59之间的秒数(00 to 61)
%U
显示一年中的第几周,星期天为一周的第一天(00 to 53)
%w
显示一周中的第几天,其中星期天为0,星期一为1(0 to 6)
%W
显示一年中的第几周,和U%把不同的是星期一为一周的第一天 (00 to 53)
%x
显示本地的日期
%X
显示本地的时间
%y
显示(00 - 99) 之间的年份(00 to 99)
%Y
显示完整年份(2016)
%Z
输出时区(GMT)
%%
用于显示%符号(%)
一个完整的示例。显示当前日期时间:格式为:年-月-日 时:分:秒>>> datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');'2016-11-17 08:06:17'
- Python 速查表
- Python正则表达式速查表
- Python开发资源速查表
- Python并发速查表
- Python 加密速查表
- Python 基础速查表
- Python
- Python
- Python
- python
- Python
- PYTHON
- Python
- Python
- Python
- Python
- Python
- Python
- Android 新一代多渠道打包神器(支持N版本新的签名方法)
- 安卓应用角标
- PAT 1040 求最长回文子串
- 面试常遇到的成绩排序问题
- 关于#ifdef _DEBUG失效问题
- Python 速查表
- 详解内部类
- LeetCode-504. Base 7 (Java)
- Mac版R语言(六)文本挖掘(用户词库的导入、批量导入搜狗词库)
- ZooKeeper机制架构
- shiro的会话工厂SessionFactory
- 运算符重载
- Redis RDB和AOF
- Kotlin java-freestyle