• pi


    pi@raspberrypi ~ $ python
    Python 2.7.3 (default, Mar 18 2014, 05:13:23) 
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> names = ('xupeng','yanfeng','dylon');
    >>> print names[3];
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    IndexError: tuple index out of range
    >>> print names[2];
    dylon
    >>> print names[1:2];
    ('yanfeng',)
    >>> print names[0:2];
    ('xupeng', 'yanfeng')
    >>> print names[-1];
    dylon
    >>> print names[-1]+names[0];
    dylonxupeng
    >>> print xupeng in names
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'xupeng' is not defined
    >>> print 'xupeng' in names
    True
    >>> print names[1]*3
    yanfengyanfengyanfeng
    >>> print names[::]
    ('xupeng', 'yanfeng', 'dylon')
    >>> s='12345679'
    >>> s[::-2]
    '9642'
    >>> i=-2
    >>> for i in range(-1,-len(s),-1):
    ... print i;
      File "<stdin>", line 2
        print i;
            ^
    IndentationError: expected an indented block
    >>> print       i;
    -2
    >>> len(s)
    8
    >>> for i in range(-1,-len(s),-1):
    ...     print s[:i]
    ... 
    1234567
    123456
    12345
    1234
    123
    12
    1
    >>> for i in range(-1,-len(s),-1):
    ...     print s[:i];print i;
    ... 
    1234567
    -1
    123456
    -2
    12345
    -3
    1234
    -4
    123
    -5
    12
    -6
    1
    -7
    >>> for i in range(-1,-len(s),1):
    ...     print s[:i];print i;
    ... 
    >>> for i in range(-1,-len(s),1):
    ...     print s[:i];print i;
    ... 
    >>> 
    >>> 
    >>> 
    >>> for i in range(-1,-len(s),-1):
    ...     print s[:i];print i;
    ... 
    1234567
    -1
    123456
    -2
    12345
    -3
    1234
    -4
    123
    -5
    12
    -6
    1
    -7
    >>> s[:-1]
    '1234567'
    >>> s[:2]
    '12'
    >>> s[:3]
    '123'
    >>> s[:-2]
    '123456'
    >>> dir(__builtins__)
    ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
    
  • 相关阅读:
    微信小程序开发学习--页面事件和数据绑定
    检测小程序版本更新提示
    vue-cli脚手架
    链表中倒数第K个结点
    调整数组顺序使奇数位于偶数前面
    数值的整数次方(十二)
    二进制中1的个数(十一)
    覆盖矩形(十)
    变态跳台阶(九)
    跳台阶(八)
  • 原文地址:https://www.cnblogs.com/flintlovesam/p/5357292.html
Copyright © 2020-2023  润新知