python-2


s = "ian"
ret = "ia" in s
print(ret)
li = ["penny","jack","ian"]
ret = "ian" in li
print(ret)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

数字:int

n1 = 123

n2 = 456

print (n1+n2)

传参>>self 不需传参>>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

字符串:str

class str(object):
    """
    str(object='') -> str
    str(bytes_or_buffer[, encoding[, errors]]) -> str
    
    Create a new string object from the given object. If encoding or
    errors is specified, then the object must expose a data buffer
    that will be decoded using the given encoding and error handler.
    Otherwise, returns the result of object.__str__() (if defined)
    or repr(object).
    encoding defaults to sys.getdefaultencoding().
    errors defaults to 'strict'.
    """
    def capitalize(self): # real signature unknown; restored from __doc__
        """
        S.capitalize() -> str
        
        Return a capitalized version of S, i.e. make the first character
        have upper case and the rest lower case.
        """
        return ""
a1 = "ian"
ret = a1.capitalize()
print(ret)

  def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
        """
        S.center(width[, fillchar]) -> str
        
        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): # real signature unknown; restored from __doc__
        """
        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 encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
        """
        S.encode(encoding='utf-8', errors='strict') -> bytes
        
        Encode S using the codec registered for encoding. Default encoding
        is 'utf-8'. 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 can handle UnicodeEncodeErrors.
        """
        return b""

    def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
        """
        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


a1 = "ian"
ret = a1.center(20,'*')
print(ret)

a1 = "ian a a a "
ret = a1.count("a")
print(ret)

a1 = "ian a a a "
# ret = a1.count("a")
ret = a1.count('a',0, 3)
print(ret)

temp = "hello"
print(temp.endswith('o'))

s = "hello {0}, age {1}"
print(s)
new1 = s.format("ian", 19)
print(new1)

a = "ian9"
ret = a.isalnum()
print(ret)

li = ["ian", "eric"]
s = "_".join(li)
print(s)
s = "   ian   "
# n = s.lstrip()
# n=s.rstrip()
n = s.strip()
print(n)


s = "ian aa  ian"
ret = s.partition("aa")
print(ret)

s = "ian aa  ian  aa"
ret = s.replace("aa", "bb", 1)
print(ret)


s = "ian"
start = 0
while start < len(s):
    temp = s[start]
    print(temp)
    start +=1

for i in s:
    if i == "a":
        break
    print(i)



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

布尔值:bool



列表:list


class list(object):
    """
    list() -> new empty list
    list(iterable) -> new list initialized from iterable's items
    """
    def append(self, p_object): # real signature unknown; restored from __doc__
        """ L.append(object) -> None -- append object to end """
        pass

    def clear(self): # real signature unknown; restored from __doc__
        """ L.clear() -> None -- remove all items from L """
        pass

    def copy(self): # real signature unknown; restored from __doc__
        """ L.copy() -> list -- a shallow copy of L """
        return []

    def count(self, value): # real signature unknown; restored from __doc__
        """ L.count(value) -> integer -- return number of occurrences of value """
        return 0

    def extend(self, iterable): # real signature unknown; restored from __doc__
        """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """
        pass

    def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
        """
        L.index(value, [start, [stop]]) -> integer -- return first index of value.
        Raises ValueError if the value is not present.
        """
        return 0

    def insert(self, index, p_object): # real signature unknown; restored from __doc__
        """ L.insert(index, object) -- insert object before index """
        pass

    def pop(self, index=None): # real signature unknown; restored from __doc__
        """
        L.pop([index]) -> item -- remove and return item at index (default last).
        Raises IndexError if list is empty or index is out of range.
        """
        pass

    def remove(self, value): # real signature unknown; restored from __doc__
        """
        L.remove(value) -> None -- remove first occurrence of value.
        Raises ValueError if the value is not present.
        """
        pass

    def reverse(self): # real signature unknown; restored from __doc__
        """ L.reverse() -- reverse *IN PLACE* """
        pass

    def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__
        """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """
        pass

    def __add__(self, *args, **kwargs): # real signature unknown
        """ Return self+value. """
        pass

    def __contains__(self, *args, **kwargs): # real signature unknown
        """ Return key in self. """
        pass


# list
# 
# name_list.append("shirly")
# name_list.append("shirly")
# name_list.append("shirly")
# print(name_list.count("shirly"))
# print(name_list)
# 
# temp = [11, 22, 33, 44]
# name_list.extend(temp)
# print(name_list)
# 
# print(name_list.index("penny"))
# name_list.insert(1,"tom")
# print(name_list)
# a1 = name_list.pop()
# print(name_list)
# 
# print(a1)
# 
# name_list.remove("shirly")
# print(name_list)
# name_list.reverse()
# print(name_list)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


元组:tuple


print(name_tuple[len(name_tuple)-1])
print(name_tuple[0:1])
for i in name_tuple:
    print(i)
print(name_tuple.index("jack"))

print(name_tuple.count("jack"))


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


字典:dict


user = {
    "name": "ian",
    "age": 11,
    "gender": "male"
}
dict
print(user["name"])

for i in user:
    print(i)
print(user.keys())
print(user.values())
print(user.items())
for i in user.keys():
    print(i)
for i in user.values():
    print(i)
for i in user.items():
    print(i)
get
val = user.get("age")
print(val)
val = user.get("age111", "123")
print(val)

# ret = "age" in user.keys()
# print(ret)
print(user)
test = {
    "1": 123,
    "2": 456,
}
user.update(test)
print(user)


temp = "ian"
print(temp)
temp_new = temp.upper()
print(temp_new)
temp = "ian"
#通过type获取字符串 类型
jack = type(temp)
print(jack)
print(type(temp))
str
#调用功能
temp_new = temp.upper()
print(temp_new)

#查看对象的类,对象的功能   type    dir    help
temp = "ian"
b = dir(temp)
print(b)
temp = "ian"
help(type(temp))

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


》》》不同类型功能不同》》》功能》模板》类》对象》地址》》

方法在相对的值>(类)>对象的功能在对象相关联的类中》》》不同类型功能不同》》》功能》模板》类》对象》地址》》


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值