列举至少5个python内置函数和使用方法_6.python字符串-内置方法列举

Help on class str in module __builtin__:classstr(basestring)| str(object='') ->string|

|Return a nice string representation of the object.| If the argument is a string, the return value isthe same object.|

|Method resolution order:|str|basestring|object|

|Methods defined here:|

| __add__(...)| x.__add__(y) <==> x+y  #字符串拼接,看+号就知道

|

| __contains__(...)| x.__contains__(y) <==> y in x  #判断x里字符是否在y里

|

| __eq__(...)| x.__eq__(y) <==> x==y|

| __format__(...)| S.__format__(format_spec) ->string|

|Return a formatted version of S as described by format_spec.|

| __ge__(...)| x.__ge__(y) <==> x>=y|

| __getattribute__(...)| x.__getattribute__('name') <==> x.name  #获取属性

|

| __getitem__(...)| x.__getitem__(y) <==> x[y]  #索引取值,详情参考python中的序列

|

| __getnewargs__(...)|

| __getslice__(...)| x.__getslice__(i, j) <==> x[i:j]  #切片,也是序列的一种方法

|

| Use of negative indices is notsupported.|

| __gt__(...)| x.__gt__(y) <==> x>y|

| __hash__(...)| x.__hash__() <==>hash(x)|

| __le__(...)| x.__le__(y) <==> x<=y|

| __len__(...)| x.__len__() <==>len(x)|

| __lt__(...)| x.__lt__(y) <==> x

| __mod__(...)| x.__mod__(y) <==> x%y|

| __mul__(...)| x.__mul__(n) <==> x*n|

| __ne__(...)| x.__ne__(y) <==> x!=y|

| __repr__(...)| x.__repr__() <==>repr(x)|

| __rmod__(...)| x.__rmod__(y) <==> y%x|

| __rmul__(...)| x.__rmul__(n) <==> n*x|

| __sizeof__(...)| S.__sizeof__() -> size of S in memory, in bytes  #用字节表示在内存中的大小

|

| __str__(...)| x.__str__() <==>str(x)|

|capitalize(...)| S.capitalize() ->string| '''返回首字母大写字符串副本,对中文无效'''

|Return a copy of the string S with only its first character|capitalized.|

|center(...)| S.center(width[, fillchar]) ->string| '''返回指定宽度(width)的字符串副本,原字符串居中对齐,可指定用什么来填充多余部分(fillchar)默认为空格,关于对齐和填充可以看上篇博文的解释'''

| Return S centered in a string of length width. Padding is

| done using the specified fill character (default isa space)|

|count(...)| S.count(sub[, start[, end]]) ->int| '''计数器,返回给定字符串在原字符串出现的次数,也可指定范围'''

| Return the number of non-overlapping occurrences of substring sub in

| string S[start:end]. Optional arguments start andend are interpreted| as inslice notation.|

|decode(...)| S.decode([encoding[,errors]]) ->object| '''解码,将字符串解码成某种字符集'''

| Decodes S using the codec registered forencoding. encoding defaults|to the default encoding. errors may be given to set a different error| handling scheme. Default is 'strict' meaning that encoding errors raise

| a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'

| as well as any other name registered with codecs.register_error that is

|able to handle UnicodeDecodeErrors.|

|encode(...)| S.encode([encoding[,errors]]) ->object| '''编码,将字符串编码'''

| Encodes S using the codec registered forencoding. encoding defaults|to the default encoding. errors may be given to set a different error| handling scheme. Default is 'strict' meaning that encoding errors raise

| a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and

| 'xmlcharrefreplace'as well as any other name registered with| codecs.register_error that isable to handle UnicodeEncodeErrors.|

|endswith(...)| S.endswith(suffix[, start[, end]]) ->bool| '''判断字符串在某范围内(范围用索引指定,不指定默认是整个字符串)是否以指定的字符串(suffix)结尾,返回布尔值'''

| Return True ifS ends with the specified suffix, False otherwise.|With optional start, test S beginning at that position.|With optional end, stop comparing S at that position.| suffix can also be a tuple of strings to try.|

|expandtabs(...)| S.expandtabs([tabsize]) ->string| '''将字符串里的制表符(一般用tab建输入,也可以手动使用特殊字符 \t )转换成空格,默认一个制表符转换成8个空格,也可以指定个数(tabsize),并返回一个转换后的副本'''

|Return a copy of S where all tab characters are expanded using spaces.| If tabsize is not given, a tab size of 8 characters isassumed.|

|find(...)| S.find(sub [,start [,end]]) ->int| '''在原字符串一定范围内,寻找给定的字符串,找到了返回第一个被找到的字符的索引值,没找到就返回-1'''

| Return the lowest index in S where substring sub isfound,| such that sub iscontained within S[start:end]. Optional| arguments start and end are interpreted as inslice notation.|

| Return -1on failure.|

|format(...)| S.format(*args, **kwargs) ->string| '''字符串格式化(比%s更为高级,需要的话自行去了解),(*args, **kwargs)是处理函数传参的一种方式,以后继续讲'''

| Return a formatted version of S, using substitutions from args andkwargs.| The substitutions are identified by braces ('{' and '}').|

|index(...)| S.index(sub [,start [,end]]) ->int| '''和S.find()作用一样,只不过没找到时会报错'''

| Like S.find() but raise ValueError when the substring is notfound.|

|isalnum(...)| S.isalnum() ->bool| '''判断字符串内是否由字母和数字组成,返回布尔值'''

| Return True if all characters inS are alphanumeric| and there is at least one character inS, False otherwise.|

|isalpha(...)| S.isalpha() ->bool| '''判断字符串是否全是由字母组成,返回布尔值'''

| Return True if all characters inS are alphabetic| and there is at least one character inS, False otherwise.|

|isdigit(...)| S.isdigit() ->bool| '''判断字符串是否全是由数字组成,返回布尔值'''

| Return True if all characters inS are digits| and there is at least one character inS, False otherwise.|

|islower(...)| S.islower() ->bool| '''判断字符串里的所有字母是否都是小写,当然,前提是字符串里面最少有一个字母,返回布尔值'''

| Return True if all cased characters in S are lowercase and there is

| at least one cased character inS, False otherwise.|

|isspace(...)| S.isspace() ->bool| '''判断字符串是否都是由空白字符组成(空格),当然,前提是字符串里面最少有一个空格,返回布尔值'''

| Return True if all characters inS are whitespace| and there is at least one character inS, False otherwise.|

|istitle(...)| S.istitle() ->bool| '''判断字符串是否是标题,而标题的标准就是所有单词的首字母都是大写,其他的都是小写,返回布尔值'''

| Return True if S is a titlecased string and there isat least one| character inS, i.e. uppercase characters may only follow uncased| characters andlowercase characters only cased ones. Return False|otherwise.|

|isupper(...)| S.isupper() ->bool| '''判断字符串里的所有字母是否都是大写,和小写对应'''

| Return True if all cased characters in S are uppercase and there is

| at least one cased character inS, False otherwise.|

|join(...)| S.join(iterable) ->string| '''字符串的拼接,详情看我前面的博文'''

| Return a string which is the concatenation of the strings inthe| iterable. The separator between elements isS.|

|ljust(...)| S.ljust(width[, fillchar]) ->string| '''左对齐,关于对齐和填充可以看我上篇博文'''

| Return S left-justified in a string of length width. Padding is

| done using the specified fill character (default isa space).|

|lower(...)| S.lower() ->string| '''返回一个全是小写的字符串副本'''

|Return a copy of the string S converted to lowercase.|

|lstrip(...)| S.lstrip([chars]) -> string orunicode| '''和strip类似,不过只去除左边的空格,可以指定字符'''

|Return a copy of the string S with leading whitespace removed.| If chars is given and not None, remove characters inchars instead.| If chars isunicode, S will be converted to unicode before stripping|

|partition(...)| S.partition(sep) ->(head, sep, tail)| '''和 split 的分隔类似,但返回的是元祖,不过 split 不过保留给定字符,translate 则会保留,并放在中间,没找到则前后为空'''

| Search for the separator sep in S, and returnthe part before it,| the separator itself, and the part after it. If the separator is not

| found, return S andtwo empty strings.|

|replace(...)| S.replace(old, new[, count]) ->string| '''替换,用新的字符串(new),替换原字符串里有的老字符串(old),用 count 指定替换的次数,不指定则全部替换'''

|Return a copy of string S with all occurrences of substring| old replaced by new. If the optional argument count is

|given, only the first count occurrences are replaced.|

|rfind(...)| S.rfind(sub [,start [,end]]) ->int| '''和S.find()作用类似,不过寻找方向是从右向左'''

| Return the highest index in S where substring sub isfound,| such that sub iscontained within S[start:end]. Optional| arguments start and end are interpreted as inslice notation.|

| Return -1on failure.|

|rindex(...)| S.rindex(sub [,start [,end]]) ->int| '''和S.index()作用类似,不过寻找方向是从右向左'''

| Like S.rfind() but raise ValueError when the substring is notfound.|

|rjust(...)| S.rjust(width[, fillchar]) ->string| '''右对齐'''

| Return S right-justified in a string of length width. Padding is

| done using the specified fill character (default isa space)|

|rpartition(...)| S.rpartition(sep) ->(head, sep, tail)| '''partition 的右边操作版本'''

| Search for the separator sep in S, starting at the end of S, and return

| the part before it, the separator itself, andthe part after it. If the| separator is not found, return two empty strings andS.|

|rsplit(...)| S.rsplit([sep [,maxsplit]]) ->list of strings| '''split 的右边操作版,要设置了 maxsplit 才能体现,否则都是全部分隔'''

| Return a list of the words inthe string S, using sep as the| delimiter string, starting at the end of the string andworking| to the front. If maxsplit isgiven, at most maxsplit splits are| done. If sep is not specified or isNone, any whitespace string| isa separator.|

|rstrip(...)| S.rstrip([chars]) -> string orunicode| '''和strip类似,不过只去除右边的空格,可以指定字符'''

|Return a copy of the string S with trailing whitespace removed.| If chars is given and not None, remove characters inchars instead.| If chars isunicode, S will be converted to unicode before stripping|

|split(...)| S.split([sep [,maxsplit]]) ->list of strings| '''按照给定的字符进行分割(从左边开始,找到的第一个),返回一个分割由后剩下的字符串组成的列表(不保留sep),

|      maxsplit 指定最大分割次数,否则凡是出现指定的分隔符都会分隔'''

| Return a list of the words inthe string S, using sep as the| delimiter string. If maxsplit isgiven, at most maxsplit| splits are done. If sep is not specified or isNone, any| whitespace string is a separator andempty strings are removed| fromthe result.|

|splitlines(...)| S.splitlines(keepends=False) ->list of strings| '''根据换行符分割'''

| Return a list of the lines inS, breaking at line boundaries.| Line breaks are not included inthe resulting list unless keepends| is given andtrue.|

|startswith(...)| S.startswith(prefix[, start[, end]]) ->bool| '''判断是否已指定字符串开头,与上面的结尾判断相对应'''

| Return True ifS starts with the specified prefix, False otherwise.|With optional start, test S beginning at that position.|With optional end, stop comparing S at that position.| prefix can also be a tuple of strings to try.|

|strip(...)| S.strip([chars]) -> string orunicode| '''与 center 的填充相反,这里是移除两边的填充,同样也可以指定移除填充的字符,默认是空格,和 center 类似'''

| Return a copy of the string S with leading andtrailing|whitespace removed.| If chars is given and not None, remove characters inchars instead.| If chars isunicode, S will be converted to unicode before stripping|

|swapcase(...)| S.swapcase() ->string| '''返回一个翻转原字符串字母大小写后的副本'''

|Return a copy of the string S with uppercase characters| converted to lowercase andvice versa.|

|title(...)| S.title() ->string| '''将字符串转换为标题格式'''

|Return a titlecased version of S, i.e. words start with uppercase|characters, all remaining cased characters have lowercase.|

|translate(...)| S.translate(table [,deletechars]) ->string| '''根据参数table给出的表(翻译表,翻译表是通过maketrans方法转换而来)转换字符串的字符, 要过滤掉的字符放到 del 参数中'''

|Return a copy of the string S, where all characters occurring| in the optional argument deletechars are removed, andthe|remaining characters have been mapped through the given| translation table, which must be a string of length 256 orNone.| If the table argument is None, no translation is applied and

| the operation simply removes the characters indeletechars.|

|upper(...)| S.upper() ->string| '''将字符串的字母全部大写'''

|Return a copy of the string S converted to uppercase.|

|zfill(...)| S.zfill(width) ->string| '''返回一个给定长度的字符串(小于原字符串无效),原字符右对齐,前面用0填充'''

|Pad a numeric string S with zeros on the left, to fill a field| of the specified width. The string S isnever truncated.|

| ----------------------------------------------------------------------

| Data andother attributes defined here:|

| __new__ =

| T.__new__(S, ...) -> a new object with type S, a subtype of T

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1 目标检测的定义 目标检测(Object Detection)的任务是找出图像中所有感兴趣的目标(物体),确定它们的类别和位置,是计算机视觉领域的核心问题之一。由于各类物体有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具有挑战性的问题。 目标检测任务可分为两个关键的子任务,目标定位和目标分类。首先检测图像中目标的位置(目标定位),然后给出每个目标的具体类别(目标分类)。输出结果是一个边界框(称为Bounding-box,一般形式为(x1,y1,x2,y2),表示框的左上角坐标和右下角坐标),一个置信度分数(Confidence Score),表示边界框中是否包含检测对象的概率和各个类别的概率(首先得到类别概率,经过Softmax可得到类别标签)。 1.1 Two stage方法 目前主流的基于深度学习的目标检测算法主要分为两类:Two stage和One stage。Two stage方法将目标检测过程分为两个阶段。第一个阶段是 Region Proposal 生成阶段,主要用于生成潜在的目标候选框(Bounding-box proposals)。这个阶段通常使用卷积神经网络(CNN)从输入图像中提取特征,然后通过一些技巧(如选择性搜索)来生成候选框。第二个阶段是分类和位置精修阶段,将第一个阶段生成的候选框输入到另一个 CNN 中进行分类,并根据分类结果对候选框的位置进行微调。Two stage 方法的优点是准确度较高,缺点是速度相对较慢。 常见Tow stage目标检测算法有:R-CNN系列、SPPNet等。 1.2 One stage方法 One stage方法直接利用模型提取特征值,并利用这些特征值进行目标的分类和定位,不需要生成Region Proposal。这种方法的优点是速度快,因为省略了Region Proposal生成的过程。One stage方法的缺点是准确度相对较低,因为它没有对潜在的目标进行预先筛选。 常见的One stage目标检测算法有:YOLO系列、SSD系列和RetinaNet等。 2 常见名词解释 2.1 NMS(Non-Maximum Suppression) 目标检测模型一般会给出目标的多个预测边界框,对成百上千的预测边界框都进行调整肯定是不可行的,需要对这些结果先进行一个大体的挑选。NMS称为非极大值抑制,作用是从众多预测边界框中挑选出最具代表性的结果,这样可以加快算法效率,其主要流程如下: 设定一个置信度分数阈值,将置信度分数小于阈值的直接过滤掉 将剩下框的置信度分数从大到小排序,选中值最大的框 遍历其余的框,如果和当前框的重叠面积(IOU)大于设定的阈值(一般为0.7),就将框删除(超过设定阈值,认为两个框的里面的物体属于同一个类别) 从未处理的框中继续选一个置信度分数最大的,重复上述过程,直至所有框处理完毕 2.2 IoU(Intersection over Union) 定义了两个边界框的重叠度,当预测边界框和真实边界框差异很小时,或重叠度很大时,表示模型产生的预测边界框很准确。边界框A、B的IOU计算公式为: 2.3 mAP(mean Average Precision) mAP即均值平均精度,是评估目标检测模型效果的最重要指标,这个值介于0到1之间,且越大越好。mAP是AP(Average Precision)的平均值,那么首先需要了解AP的概念。想要了解AP的概念,还要首先了解目标检测中Precision和Recall的概念。 首先我们设置置信度阈值(Confidence Threshold)和IoU阈值(一般设置为0.5,也会衡量0.75以及0.9的mAP值): 当一个预测边界框被认为是True Positive(TP)时,需要同时满足下面三个条件: Confidence Score > Confidence Threshold 预测类别匹配真实值(Ground truth)的类别 预测边界框的IoU大于设定的IoU阈值 不满足条件2或条件3,则认为是False Positive(FP)。当对应同一个真值有多个预测结果时,只有最高置信度分数的预测结果被认为是True Positive,其余被认为是False Positive。 Precision和Recall的概念如下图所示: Precision表示TP与预测边界框数量的比值 Recall表示TP与真实边界框数量的比值 改变不同的置信度阈值,可以获得多组Precision和Recall,Recall放X轴,Precision放Y轴,可以画出一个Precision-Recall曲线,简称P-R
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值