2.布尔值

真或假

1或0

3.字符串类型

"hello world"

字符串常用功能:

-移除空白

-分隔

-长度

-索引

-切片

class str(basestring):

"""

str(object='') -> string

Return a nice string representation of the object.

If the argument is a string, the return value is the same object.

"""

def capitalize(self):

"""

a="leoday"

temp=a.capitalize()

print  (temp)

这直接是输出的Leoday

"""

""" 首字母变大写 """

"""

S.capitalize() -> string

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

capitalized.

"""

return ""

def center(self, width, fillchar=None):

"""

a=leoday

temp=a.center(20,****)

print  (temp)

输出的结果是:******temp******

"""

""" 内容居中,width:总长度;fillchar:空白处填充内容,默认无 """

"""

S.center(width[, fillchar]) -> string

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

done using the specified fill character (default is a space)

"""

return ""

def count(self, sub, start=None, end=None):

"""

这个不明白,什么是子序列个数

"""

""" 子序列个数 """

"""

S.count(sub[, start[, end]]) -> int

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

string S[start:end]. Optional arguments start and end are interpreted

as in slice notation.

"""

return 0

def decode(self, encoding=None, errors=None):

"""

这个不明白,什么是解码后面俩参数怎么写的

"""

""" 解码 """

"""

S.decode([encoding[,errors]]) -> object

Decodes S using the codec registered for encoding. 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.

"""

return object()

def encode(self, encoding=None, errors=None):

"""

这个不明白,编码后面俩参数的具体写法

"""

""" 编码,针对unicode """

"""

S.encode([encoding[,errors]]) -> object

Encodes S using the codec registered for encoding. 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 is able to handle UnicodeEncodeErrors.

"""

return object()

def endswith(self, suffix, start=None, end=None):

""" 是否以 xxx 结束 """

"""

S.endswith(suffix[, start[, end]]) -> bool

Return True if S 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.

"""

return False

def expandtabs(self, tabsize=None):

""" 将tab转换成空格,默认一个tab转换成8个空格 """

"""

S.expandtabs([tabsize]) -> string

Return a copy of S where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

"""

return ""

def find(self, sub, start=None, end=None):

""" 寻找子序列位置,如果没找到,返回 -1 """

"""

S.find(sub [,start [,end]]) -> int

Return the lowest index in S where substring sub is found,

such that sub is contained within S[start:end]. Optional

arguments start and end are interpreted as in slice notation.

Return -1 on failure.

"""

return 0

def format(*args, **kwargs): # known special case of str.format

""" 字符串格式化,动态参数,将函数式编程时细说 """

"""

S.format(*args, **kwargs) -> string

Return a formatted version of S, using substitutions from args and kwargs.

The substitutions are identified by braces ('{' and '}').

"""

pass

def index(self, sub, start=None, end=None):

""" 子序列位置,如果没找到,报错 """

S.index(sub [,start [,end]]) -> int

Like S.find() but raise ValueError when the substring is not found.

"""

return 0

def isalnum(self):

""" 是否是字母和数字 """

"""

S.isalnum() -> bool

Return True if all characters in S are alphanumeric

and there is at least one character in S, False otherwise.

"""

return False

def isalpha(self):

""" 是否是字母 """

"""

S.isalpha() -> bool

Return True if all characters in S are alphabetic

and there is at least one character in S, False otherwise.

"""

return False

def isdigit(self):

""" 是否是数字 """

"""

S.isdigit() -> bool

Return True if all characters in S are digits

and there is at least one character in S, False otherwise.

"""

return False

def islower(self):

""" 是否小写 """

"""

S.islower() -> bool

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

at least one cased character in S, False otherwise.

"""

return False

def isspace(self):

"""

S.isspace() -> bool

Return True if all characters in S are whitespace

and there is at least one character in S, False otherwise.

"""

return False

def istitle(self):

"""

S.istitle() -> bool

Return True if S is a titlecased string and there is at least one

character in S, i.e. uppercase characters may only follow uncased

characters and lowercase characters only cased ones. Return False

otherwise.

"""

return False

def isupper(self):

"""

S.isupper() -> bool

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

at least one cased character in S, False otherwise.

"""

return False

def join(self, iterable):

""" 连接 """

"""

S.join(iterable) -> string

Return a string which is the concatenation of the strings in the

iterable. The separator between elements is S.

"""

return ""

def ljust(self, width, fillchar=None):

""" 内容左对齐,右侧填充 """

"""

S.ljust(width[, fillchar]) -> string

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

done using the specified fill character (default is a space).

"""

return ""

def lower(self):

""" 变小写 """

"""

S.lower() -> string

Return a copy of the string S converted to lowercase.

"""

return ""

def lstrip(self, chars=None):

""" 移除左侧空白 """

"""

S.lstrip([chars]) -> string or unicode

Return a copy of the string S with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

If chars is unicode, S will be converted to unicode before stripping

"""

return ""

def partition(self, sep):

""" 分割,前,中,后三部分 """

"""

S.partition(sep) -> (head, sep, tail)

Search for the separator sep in S, and return the part before it,

the separator itself, and the part after it. If the separator is not

found, return S and two empty strings.

"""

pass

def replace(self, old, new, count=None):

""" 替换 """

"""

S.replace(old, new[, count]) -> string

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.

"""

return ""

def rfind(self, sub, start=None, end=None):

"""

S.rfind(sub [,start [,end]]) -> int

Return the highest index in S where substring sub is found,

such that sub is contained within S[start:end]. Optional

arguments start and end are interpreted as in slice notation.

Return -1 on failure.

"""

return 0

def rindex(self, sub, start=None, end=None):

"""

S.rindex(sub [,start [,end]]) -> int

Like S.rfind() but raise ValueError when the substring is not found.

"""

return 0

def rjust(self, width, fillchar=None):

"""

S.rjust(width[, fillchar]) -> string

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

done using the specified fill character (default is a space)

"""

return ""

def rpartition(self, sep):

"""

S.rpartition(sep) -> (head, sep, tail)

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

the part before it, the separator itself, and the part after it. If the

separator is not found, return two empty strings and S.

"""

pass

def rsplit(self, sep=None, maxsplit=None):

"""

S.rsplit([sep [,maxsplit]]) -> list of strings

Return a list of the words in the string S, using sep as the

delimiter string, starting at the end of the string and working

to the front. If maxsplit is given, at most maxsplit splits are

done. If sep is not specified or is None, any whitespace string

is a separator.

"""

return []

def rstrip(self, chars=None):

"""

S.rstrip([chars]) -> string or unicode

Return a copy of the string S with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

If chars is unicode, S will be converted to unicode before stripping

"""

return ""

def split(self, sep=None, maxsplit=None):

""" 分割, maxsplit最多分割几次 """

"""

S.split([sep [,maxsplit]]) -> list of strings

Return a list of the words in the string S, using sep as the

delimiter string. If maxsplit is given, at most maxsplit

splits are done. If sep is not specified or is None, any

whitespace string is a separator and empty strings are removed

from the result.

"""

return []

def splitlines(self, keepends=False):

""" 根据换行分割 """

"""

S.splitlines(keepends=False) -> list of strings

Return a list of the lines in S, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends

is given and true.

"""

return []

def startswith(self, prefix, start=None, end=None):

""" 是否起始 """

"""

S.startswith(prefix[, start[, end]]) -> bool

Return True if S 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.

"""

return False

def strip(self, chars=None):

""" 移除两段空白 """

"""

S.strip([chars]) -> string or unicode

Return a copy of the string S with leading and trailing

whitespace removed.

If chars is given and not None, remove characters in chars instead.

If chars is unicode, S will be converted to unicode before stripping

"""

return ""

def swapcase(self):

""" 大写变小写,小写变大写 """

"""

S.swapcase() -> string

Return a copy of the string S with uppercase characters

converted to lowercase and vice versa.

"""

return ""

def title(self):

"""

S.title() -> string

Return a titlecased version of S, i.e. words start with uppercase

characters, all remaining cased characters have lowercase.

"""

return ""

def translate(self, table, deletechars=None):

"""

转换,需要先做一个对应表,最后一个表示删除字符集合

intab = "aeiou"

outtab = "12345"

trantab = maketrans(intab, outtab)

str = "this is string example....wow!!!"

print str.translate(trantab, 'xm')

"""

"""

S.translate(table [,deletechars]) -> string

Return a copy of the string S, where all characters occurring

in the optional argument deletechars are removed, and the

remaining characters have been mapped through the given

translation table, which must be a string of length 256 or None.

If the table argument is None, no translation is applied and

the operation simply removes the characters in deletechars.

"""

return ""

def upper(self):

"""

S.upper() -> string

Return a copy of the string S converted to uppercase.

"""

return ""

def zfill(self, width):

"""方法返回指定长度的字符串,原字符串右对齐,前面填充0。"""

"""

S.zfill(width) -> string

Pad a numeric string S with zeros on the left, to fill a field

of the specified width. The string S is never truncated.

"""

return ""

def _formatter_field_name_split(self, *args, **kwargs): # real signature unknown

pass

def _formatter_parser(self, *args, **kwargs): # real signature unknown

pass

def __add__(self, y):

""" x.__add__(y) <==> x+y """

pass

def __contains__(self, y):

""" x.__contains__(y) <==> y in x """

pass

def __eq__(self, y):

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

pass

def __format__(self, format_spec):

"""

S.__format__(format_spec) -> string

Return a formatted version of S as described by format_spec.

"""

return ""

def __getattribute__(self, name):

""" x.__getattribute__('name') <==> x.name """

pass

def __getitem__(self, y):

""" x.__getitem__(y) <==> x[y] """

pass

def __getnewargs__(self, *args, **kwargs): # real signature unknown

pass

def __getslice__(self, i, j):

"""

x.__getslice__(i, j) <==> x[i:j]

Use of negative indices is not supported.

"""

pass

def __ge__(self, y):

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

pass

def __gt__(self, y):

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

pass

def __hash__(self):

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

pass

def __init__(self, string=''): # known special case of str.__init__

"""

str(object='') -> string

Return a nice string representation of the object.

If the argument is a string, the return value is the same object.

# (copied from class doc)

"""

pass

def __len__(self):

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

pass

def __le__(self, y):

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

pass

def __lt__(self, y):

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

pass

def __mod__(self, y):

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

pass

def __mul__(self, n):

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

pass

@staticmethod # known case of __new__

def __new__(S, *more):

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

pass

def __ne__(self, y):

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

pass

def __repr__(self):

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

pass

def __rmod__(self, y):

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

pass

def __rmul__(self, n):

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

pass

def __sizeof__(self):

""" S.__sizeof__() -> size of S in memory, in bytes """

pass

def __str__(self):

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

pass

python中字符串的布尔值_day02python中的基本数据类型-布尔值和字符串相关推荐

  1. python的数字类型有哪些子类型_PYTHON-基本数据类型-数字类型,字符串类型,列表类型-练习...

    # 字符串练习 # 写代码,有如下变量,请按照要求实现每个功能 (共6分,每小题各0.5分) # name = " aleX" # # 1) 移除 name 变量对应的值两边的空格 ...

  2. python中axis和value_python – 在pyqtgraph中的x轴上显示字符串值

    通常在pyqtgraph中处理自定义轴字符串时,人们将子类化为 AxisItem并使用他们想要显示的字符串覆盖 tickStrings. Pyqtgraphs axisitem还有一个内置的setTi ...

  3. python修改列表中字典内的值_python修改字典内key对应值的方法

    python学习笔记:字典 python版本:Python 2.6.6 系统环境:CentOS release 6.2 x86_64 本文参考了互联网上前辈的一些文章 一.字典是python中最灵活的 ...

  4. 【Python】进制、计算机中的单位、编码、数据类型、索引、字符串切片、字符串的功能方法

    一.进制 计算机中底层所有的数据都是以 010101 的形式存在(图片.文本.视频等). 二进制 八进制 十进制(也就是我们熟知的阿拉伯数字) 十六进制 进制转换 v1 = bin(25) # 十进制 ...

  5. python中用于标识字符串的定界符_python学习[第六篇] 数据类型之 字符串一

    数据类型之 字符串一 字符串操作 创建及赋值 x = 'abcde'x= "abcde"x= '''abcde'''x= """abcde" ...

  6. python字符串数组中最短的_python求解数组中两个字符串的最小距离

    题目: 给定一个数组 strs,其中的数据都是字符串,给定两个字符串 str1,str2.如果这两个字符串都在 strs数组中,就返回它们之间的最小距离:如果其中任何一个不在里面,则返回 -1:如果两 ...

  7. python中指定变量为1byte_Python读字节某一位的值,设置某一位的值,二进制位操作...

    Python读字节某一位的值,设置某一位的值,二进制位操作 ??在物联网实际应用项目开发中,为了提升性能,与设备端配合,往往最终使用的是二进制字节串方式进行的通信协议封装,更会把0和1.True和Fa ...

  8. python中的is判断引用的对象是否一致,==判断值是否相等

    python中的is判断引用的对象是否一致,==判断值是否相等 a = 10 b = 20 list = [1,2,3,4,5] print(a in list) print(b not in lis ...

  9. python中定义元组的符号_python中得元组和字符串详解,有这么一篇文章就够了

    本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理 以下文章来源于腾讯云 作者:咸鱼学Python ( 想要学习Python?Pyth ...

最新文章

  1. hdu5701-中位数计数
  2. 洛谷 P1034 矩形覆盖
  3. CentOS 6.0 系统 LAMP(Apache+MySQL+PHP)安装步骤
  4. 【详细了解】Nginx 除了负载均衡,还能做什么?
  5. 周源:知乎的未来是什么
  6. 动态规划原理介绍(附7个算例,有代码讲解)
  7. 全新尝试|ComponentOne WinForm和.NET Core 3.0
  8. 多用户远程连接mysql_Mysql权限控制 - 允许用户远程连接
  9. JavaScript canvas实现俄罗斯方块
  10. 超大杯来了!一加10 Ultra将在第三季度登场:或搭载OPPO 自研影像芯片
  11. 苹果应用审核团队:每人日审百款 App!
  12. C语言文件拷贝-四种方式
  13. iOS:NO suitable application records were found.Verify your bundle identifier 'com***'is correct
  14. truffle部署到测试网rinkeby
  15. 多线程Socket传送文件的客户端和服务端源代码
  16. JDK官网下载速度缓慢解决方法
  17. ios vue 添加本地音乐_vue怎么添加音乐 vue怎么添加手机音乐
  18. 学计算机应用表白,521.1314表白的数学题 学霸间的表白方式
  19. 【高中数学教资】教案设计通用模板
  20. Python中next()函数、iter()以及next(iter())函数的用法详解

热门文章

  1. Butterknife与各种事件
  2. invalidateRect解析
  3. java invalidate_InvalidateRect | 学步园
  4. 水利万物而不争,英特尔的云战略自有深意
  5. 转载:Open Sound System (OSS) 研究笔记 作者联系方式:Li XianJing
  6. 子集 || — Python
  7. PHPExcel 各种属性操作
  8. 二自由度汽车模型推导全过程
  9. 详解BFS,Dijkstra算法,Floyd算法是如何解决最短路径问题的
  10. rowspan无效_关于在 table 中给 td 设定 position:absolute 引起的 rowspan 失效的问题