<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

                    ???? Python ???
                    ??13?? ??
                    ???? ?????? ????

                    ??????

                    ????????raise??? ???? ???????????????/?????????????? ?????? ?????????????????????????÷???????Error??Exception??????????????

                    ?????????

                    ??13.2 ?????????

                    #!/usr/bin/python
                    # Filename: raising.py


                    class ShortInputException(Exception):
                        '''A user-defined exception class.'''
                        def __init__(self, length, atleast):
                            Exception.__init__(self)
                            self.length = length
                            self.atleast = atleast


                    try:
                        s =
                    raw_input('Enter something --> ')
                        if len(s) < 3:
                            raise ShortInputException(
                    len(s), 3)
                        # Other work can continue as usual here
                    except EOFError:
                        print '\nWhy did you do an EOF on me?'
                    except ShortInputException, x:
                        print 'ShortInputException: The input was of length %d, \
                              was expecting at least %d'
                    % (x.length, x.atleast)
                    else:
                        print 'No exception was raised.'

                    ??????code/raising.py??

                    ???

                    $ python raising.py
                    Enter something -->
                    Why did you do an EOF on me?

                    $ python raising.py
                    Enter something --> ab
                    ShortInputException: The input was of length 2, was expecting at least 3

                    $ python raising.py
                    Enter something --> abc
                    No exception was raised.

                    ????ι???

                    ???????????????????????????????????????????κ?????????/????????μ?????????ShortInputException??????????????length??????????????atleast???????????????С?????

                    ??except????У??????????????????????????/???????????????????????е??βκ???θ?????????????????except????У???????????????length??atleast????????????????????????


                    ???? ????? ????
                    try..except ??? try..finally
                    ?????
                    @ssv

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频