编辑代码

def built_in():
    print("""Python 3.6.6 (qpyc:3.6.6, Jul 26 2018, 03:54:22) [BUILD WITH QPY3-TOOLCHAIN (https://github.com/qpython-android) ] on linux
Type "help", "copyright", "credits" or "license" for more information.""")
    ps1=">>> "
    ps2="... "
    In=""
    Err="""Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
"""
    Errors=False
    class built_in_out(Exception):
        def __init__(self,Error):
            self.Error=Error
        def __str__(self):
            print(self.Error)
    while 1:
        Errors=False
        try:
            In=input(ps1)
            eval(In)
        except UnicodeDecodeError  as err:
            print(Err,end="")
            print(repr(err))
        except Exception:pass
        else:continue
        if (":" in In) or Errors:
            Codes=[]
            Codes.append(In)
            while In!="":
                try:
                    In=input(ps2)
                    Codes.append(In)
                except UnicodeDecodeError as err:
                    print(Err,end="")
                    print(repr(err))
                except KeyboardInterrupt as err:
                    print(Err,end="")
                    print(repr(err))
            In=""
            for i in range(len(Codes)):
                In=str(In)+str(Codes[i])+"\n"
            try:
                eval(In)
            except UnicodeDecodeError  as err:
                print(Err,end="")
                print(repr(err))
            except :
                try:
                    exec(In)
                except KeyboardInterrupt as err:
                    print(Err,end="")
                    print(repr(err))
                except Exception as err:
                    print(Err,end="")
                    print(repr(err))
        else:
            try:
                eval(In)
            except UnicodeDecodeError  as err:
                print(Err,end="")
                print(repr(err))
            except :
                try:
                    exec(In)
                except KeyboardInterrupt as err:
                    print(Err,end="")
                    print(repr(err))
                except Exception as err:
                    print(Err,end="")
                    print(repr(err))
built_in()