python 字符串

1. join(self, ab=None, pq=None, rs=None): # real signature unknown; restored from __doc__

    """
Concatenate any number of strings.

The string whose method is called is inserted in between each given string.
The result is returned as a new string.

Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'
a = "你不是美女!"
print(a)
b = "***"
c = b.join(a)
print(c)

——————-
你不是美女!
你***不***是***美***女***!

2. split(self, *args, **kwargs): # real signature unknown

a = 'jfwiefuieowir'
b = a.split('i',2)
print(b)
__________
['jfw', 'efu', 'eowir']

  

a = 'jfwiefuieowir'
b = a.split('i')
print(b)
______________
['jfw', 'efu', 'eow', 'r']

3. find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

    """
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
a = 'jfwiefuieowir'
b = a.find('u',2,10)
print(b)
_________

6

 4.  strip(self, *args, **kwargs): # real signature unknown

    """
Return a copy of the string with leading and trailing whitespace remove.

If chars is given and not None, remove characters in chars instead.
"""
pass
a = '    jfwiefuieowir      '
b = a.strip() #删除前面和后面的空格
c = a.lstrip() #删除左面的空格
d = a.rstrip() #删除右面的空格
print(a,'
',b,'
',c,'
',d)

________________________

    jfwiefuieowir       
 jfwiefuieowir 
 jfwiefuieowir       
     jfwiefuieowir

5. lower(self, *args, **kwargs): # real signature unknown

    """ Return a copy of the string converted to lowercase. """
pass
 upper(self, *args, **kwargs): # real signature unknown
""" Return a copy of the string converted to uppercase. """
pass
a = 'TjkdFGklfsaYYY'
b = a.lower()
c = a.upper()
print(a,'
',b,'
',c,'
')
___________________

TjkdFGklfsaYYY 
 tjkdfgklfsayyy 
 TJKDFGKLFSAYYY 

  




 
原文地址:https://www.cnblogs.com/jijianhu/p/10306598.html