{"id":427,"date":"2017-10-11T14:51:40","date_gmt":"2017-10-11T06:51:40","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=427"},"modified":"2017-10-11T14:51:40","modified_gmt":"2017-10-11T06:51:40","slug":"unicodedecodeerror-ascii-codec-cant-decode-byte-0xe9-in-position-0-ordinal-not-in-range128-%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=427","title":{"rendered":"UnicodeDecodeError: &#8216;ascii&#8217; codec can&#8217;t decode byte 0xe9 in position 0: ordinal not in range(128) \u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<p>\u6700\u8fd1\u5728\u7528Python\u5904\u7406\u4e2d\u6587\u5b57\u7b26\u4e32\u65f6\uff0c\u62a5\u51fa\u4e86\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>1\u3001\u539f\u56e0<\/strong><\/p>\n<p>\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cPython\u91c7\u7528\u7684\u662fascii\u7f16\u7801\u65b9\u5f0f\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>\u25c4\u25ba  python -c \"import sys; print sys.getdefaultencoding()\"\nascii\n\u25c4\u25ba<\/pre>\n<\/div>\n<p>\u800cPython\u5728\u8fdb\u884c\u7f16\u7801\u65b9\u5f0f\u4e4b\u95f4\u7684\u8f6c\u6362\u65f6\uff0c\u4f1a\u5c06 unicode \u4f5c\u4e3a\u201c\u4e2d\u95f4\u7f16\u7801\u201d\uff0c\u4f46 unicode \u6700\u5927\u53ea\u6709 128 \u90a3\u4e48\u957f\uff0c\u6240\u4ee5\u8fd9\u91cc\u5f53\u5c1d\u8bd5\u5c06 ascii \u7f16\u7801\u5b57\u7b26\u4e32\u8f6c\u6362\u6210&#8221;\u4e2d\u95f4\u7f16\u7801&#8221; unicode \u65f6\u7531\u4e8e\u8d85\u51fa\u4e86\u5176\u8303\u56f4\uff0c\u5c31\u62a5\u51fa\u4e86\u5982\u4e0a\u9519\u8bef\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>2\u3001\u89e3\u51b3\u529e\u6cd5<\/strong><\/p>\n<p>1\uff09\u7b2c\u4e00\u79cd\uff1a\u8fd9\u91cc\u6211\u4eec\u5c06Python\u7684\u9ed8\u8ba4\u7f16\u7801\u65b9\u5f0f\u4fee\u6539\u4e3autf-8\uff0c\u5c31\u53ef\u4ee5\u89c4\u907f\u4e0a\u8ff0\u95ee\u9898\u7684\u53d1\u751f\uff0c\u5177\u4f53\u65b9\u5f0f\uff0c\u6211\u4eec\u5728Python\u6587\u4ef6\u7684\u524d\u9762\u52a0\u4e0a\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>import sys\ndefaultencoding = 'utf-8'\nif sys.getdefaultencoding() != defaultencoding:\n    reload(sys)\n    sys.setdefaultencoding(defaultencoding)<\/pre>\n<\/div>\n<p>2\uff09\u7b2c\u4e8c\u79cd\uff1a\u6211\u4eec\u5728\/usr\/lib\/python2.7\/site-packages\/\u76ee\u5f55\u4e0b\u6dfb\u52a0\u4e00\u4e2asitecustomize.py\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>import sys\nsys.setdefaultencoding('utf-8')<\/pre>\n<\/div>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u89e3\u51b3\u6240\u6709\u9879\u76ee\u7684encoding\u95ee\u9898\uff0c\u5177\u4f53\u8bf4\u660e\u53ef\u53c2\u8003\/usr\/lib\/python2.7\/site.py\u6587\u4ef6\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<div class=\"cnblogs_code_toolbar\"><span class=\"cnblogs_code_copy\"><a title=\"\u590d\u5236\u4ee3\u7801\"><img decoding=\"async\" src=\"http:\/\/common.cnblogs.com\/images\/copycode.gif\" alt=\"\u590d\u5236\u4ee3\u7801\" \/><\/a><\/span><\/div>\n<pre>\"\"\"Append module search paths for third-party packages to sys.path.\n\n****************************************************************\n* This module is automatically imported during initialization. *\n****************************************************************\n\nIn earlier versions of Python (up to 1.5a3), scripts or modules that\nneeded to use site-specific modules would place ``import site''\nsomewhere near the top of their code.  Because of the automatic\nimport, this is no longer necessary (but code that does it still\nworks).\n\nThis will append site-specific paths to the module search path.  On\nUnix (including Mac OSX), it starts with sys.prefix and\nsys.exec_prefix (if different) and appends\nlib\/python&lt;version&gt;\/site-packages as well as lib\/site-python.\nOn other platforms (such as Windows), it tries each of the\nprefixes directly, as well as with lib\/site-packages appended.  The\nresulting directories, if they exist, are appended to sys.path, and\nalso inspected for path configuration files.\n\nFor Debian and derivatives, this sys.path is augmented with directories\nfor packages distributed within the distribution. Local addons go\ninto \/usr\/local\/lib\/python&lt;version&gt;\/dist-packages, Debian addons\ninstall into \/usr\/{lib,share}\/python&lt;version&gt;\/dist-packages.\n\/usr\/lib\/python&lt;version&gt;\/site-packages is not used.\n\nA path configuration file is a file whose name has the form\n&lt;package&gt;.pth; its contents are additional directories (one per line)\nto be added to sys.path.  Non-existing directories (or\nnon-directories) are never added to sys.path; no directory is added to\nsys.path more than once.  Blank lines and lines beginning with\n'#' are skipped. Lines starting with 'import' are executed.\n\nFor example, suppose sys.prefix and sys.exec_prefix are set to\n\/usr\/local and there is a directory \/usr\/local\/lib\/python2.5\/site-packages\nwith three subdirectories, foo, bar and spam, and two path\nconfiguration files, foo.pth and bar.pth.  Assume foo.pth contains the\nfollowing:\n\n  # foo package configuration\n  foo\n  bar\n  bletch\n\nand bar.pth contains:\n\n  # bar package configuration\n  bar\n\nThen the following directories are added to sys.path, in this order:\n\n  \/usr\/local\/lib\/python2.5\/site-packages\/bar\n  \/usr\/local\/lib\/python2.5\/site-packages\/foo\n\nNote that bletch is omitted because it doesn't exist; bar precedes foo\nbecause bar.pth comes alphabetically before foo.pth; and spam is\nomitted because it is not mentioned in either path configuration file.\n\nAfter these path manipulations, an attempt is made to import a module\nnamed sitecustomize, which can perform arbitrary additional\nsite-specific customizations.  If this import fails with an\nImportError exception, it is silently ignored.\n\n\"\"\"\n\nimport sys\nimport os\nimport __builtin__\nimport traceback\n\n# Prefixes for site-packages; add additional prefixes like \/usr\/local here\nPREFIXES = [sys.prefix, sys.exec_prefix]\n# Enable per user site-packages directory\n# set it to False to disable the feature or True to force the feature\nENABLE_USER_SITE = None\n\n# for distutils.commands.install\n# These values are initialized by the getuserbase() and getusersitepackages()\n# functions, through the main() function when Python starts.\nUSER_SITE = None\nUSER_BASE = None\n\n\ndef makepath(*paths):\n    dir = os.path.join(*paths)\n    try:\n        dir = os.path.abspath(dir)\n    except OSError:\n        pass\n    return dir, os.path.normcase(dir)\n\n\ndef abs__file__():\n    \"\"\"Set all module' __file__ attribute to an absolute path\"\"\"\n    for m in sys.modules.values():\n        if hasattr(m, '__loader__'):\n            continue   # don't mess with a PEP 302-supplied __file__\n        try:\n            m.__file__ = os.path.abspath(m.__file__)\n        except (AttributeError, OSError):\n            pass\n\n\ndef removeduppaths():\n    \"\"\" Remove duplicate entries from sys.path along with making them\n    absolute\"\"\"\n    # This ensures that the initial path provided by the interpreter contains\n    # only absolute pathnames, even if we're running from the build directory.\n    L = []\n    known_paths = set()\n    for dir in sys.path:\n        # Filter out duplicate paths (on case-insensitive file systems also\n        # if they only differ in case); turn relative paths into absolute\n        # paths.\n        dir, dircase = makepath(dir)\n        if not dircase in known_paths:\n            L.append(dir)\n            known_paths.add(dircase)\n    sys.path[:] = L\n    return known_paths\n\n\ndef _init_pathinfo():\n    \"\"\"Return a set containing all existing directory entries from sys.path\"\"\"\n    d = set()\n    for dir in sys.path:\n        try:\n            if os.path.isdir(dir):\n                dir, dircase = makepath(dir)\n                d.add(dircase)\n        except TypeError:\n            continue\n    return d\n\n\ndef addpackage(sitedir, name, known_paths):\n    \"\"\"Process a .pth file within the site-packages directory:\n       For each line in the file, either combine it with sitedir to a path\n       and add that to known_paths, or execute it if it starts with 'import '.\n    \"\"\"\n    if known_paths is None:\n        _init_pathinfo()\n        reset = 1\n    else:\n        reset = 0\n    fullname = os.path.join(sitedir, name)\n    try:\n        f = open(fullname, \"rU\")\n    except IOError:\n        return\n    with f:\n        for n, line in enumerate(f):\n            if line.startswith(\"#\"):\n                continue\n            try:\n                if line.startswith((\"import \", \"import\\t\")):\n                    exec line\n                    continue\n                line = line.rstrip()\n                dir, dircase = makepath(sitedir, line)\n                if not dircase in known_paths and os.path.exists(dir):\n                    sys.path.append(dir)\n                    known_paths.add(dircase)\n            except Exception as err:\n                print &gt;&gt;sys.stderr, \"Error processing line {:d} of {}:\\n\".format(\n                    n+1, fullname)\n                for record in traceback.format_exception(*sys.exc_info()):\n                    for line in record.splitlines():\n                        print &gt;&gt;sys.stderr, '  '+line\n                print &gt;&gt;sys.stderr, \"\\nRemainder of file ignored\"\n                break\n    if reset:\n        known_paths = None\n    return known_paths\n\n\ndef addsitedir(sitedir, known_paths=None):\n    \"\"\"Add 'sitedir' argument to sys.path if missing and handle .pth files in\n    'sitedir'\"\"\"\n    if known_paths is None:\n        known_paths = _init_pathinfo()\n        reset = 1\n    else:\n        reset = 0\n    sitedir, sitedircase = makepath(sitedir)\n    if not sitedircase in known_paths:\n        sys.path.append(sitedir)        # Add path component\n    try:\n        names = os.listdir(sitedir)\n    except os.error:\n        return\n    dotpth = os.extsep + \"pth\"\n    names = [name for name in names if name.endswith(dotpth)]\n    for name in sorted(names):\n        addpackage(sitedir, name, known_paths)\n    if reset:\n        known_paths = None\n    return known_paths\n\n\ndef check_enableusersite():\n    \"\"\"Check if user site directory is safe for inclusion\n\n    The function tests for the command line flag (including environment var),\n    process uid\/gid equal to effective uid\/gid.\n\n    None: Disabled for security reasons\n    False: Disabled by user (command line option)\n    True: Safe and enabled\n    \"\"\"\n    if sys.flags.no_user_site:\n        return False\n\n    if hasattr(os, \"getuid\") and hasattr(os, \"geteuid\"):\n        # check process uid == effective uid\n        if os.geteuid() != os.getuid():\n            return None\n    if hasattr(os, \"getgid\") and hasattr(os, \"getegid\"):\n        # check process gid == effective gid\n        if os.getegid() != os.getgid():\n            return None\n\n    return True\n\ndef getuserbase():\n    \"\"\"Returns the `user base` directory path.\n\n    The `user base` directory can be used to store data. If the global\n    variable ``USER_BASE`` is not initialized yet, this function will also set\n    it.\n    \"\"\"\n    global USER_BASE\n    if USER_BASE is not None:\n        return USER_BASE\n    from sysconfig import get_config_var\n    USER_BASE = get_config_var('userbase')\n    return USER_BASE\n\ndef getusersitepackages():\n    \"\"\"Returns the user-specific site-packages directory path.\n\n    If the global variable ``USER_SITE`` is not initialized yet, this\n    function will also set it.\n    \"\"\"\n    global USER_SITE\n    user_base = getuserbase() # this will also set USER_BASE\n\n    if USER_SITE is not None:\n        return USER_SITE\n\n    from sysconfig import get_path\n    import os\n\n    if sys.platform == 'darwin':\n        from sysconfig import get_config_var\n        if get_config_var('PYTHONFRAMEWORK'):\n            USER_SITE = get_path('purelib', 'osx_framework_user')\n            return USER_SITE\n\n    USER_SITE = get_path('purelib', '%s_user' % os.name)\n    return USER_SITE\n\ndef addusersitepackages(known_paths):\n    \"\"\"Add a per user site-package to sys.path\n\n    Each user has its own python directory with site-packages in the\n    home directory.\n    \"\"\"\n    # get the per user site-package path\n    # this call will also make sure USER_BASE and USER_SITE are set\n    user_site = getusersitepackages()\n\n    if ENABLE_USER_SITE and os.path.isdir(user_site):\n        addsitedir(user_site, known_paths)\n    if ENABLE_USER_SITE:\n        for dist_libdir in (\"local\/lib\", \"lib\"):\n            user_site = os.path.join(USER_BASE, dist_libdir,\n                                     \"python\" + sys.version[:3],\n                                     \"dist-packages\")\n            if os.path.isdir(user_site):\n                addsitedir(user_site, known_paths)\n    return known_paths\n\ndef getsitepackages():\n    \"\"\"Returns a list containing all global site-packages directories\n    (and possibly site-python).\n\n    For each directory present in the global ``PREFIXES``, this function\n    will find its `site-packages` subdirectory depending on the system\n    environment, and will return a list of full paths.\n    \"\"\"\n    sitepackages = []\n    seen = set()\n\n    for prefix in PREFIXES:\n        if not prefix or prefix in seen:\n            continue\n        seen.add(prefix)\n\n        if sys.platform in ('os2emx', 'riscos'):\n            sitepackages.append(os.path.join(prefix, \"Lib\", \"site-packages\"))\n        elif os.sep == '\/':\n            sitepackages.append(os.path.join(prefix, \"local\/lib\",\n                                        \"python\" + sys.version[:3],\n                                        \"dist-packages\"))\n            sitepackages.append(os.path.join(prefix, \"lib\",\n                                        \"python\" + sys.version[:3],\n                                        \"dist-packages\"))\n        else:\n            sitepackages.append(prefix)\n            sitepackages.append(os.path.join(prefix, \"lib\", \"site-packages\"))\n        if sys.platform == \"darwin\":\n            # for framework builds *only* we add the standard Apple\n            # locations.\n            from sysconfig import get_config_var\n            framework = get_config_var(\"PYTHONFRAMEWORK\")\n            if framework:\n                sitepackages.append(\n                        os.path.join(\"\/Library\", framework,\n                            sys.version[:3], \"site-packages\"))\n    return sitepackages\n\ndef addsitepackages(known_paths):\n    \"\"\"Add site-packages (and possibly site-python) to sys.path\"\"\"\n    for sitedir in getsitepackages():\n        if os.path.isdir(sitedir):\n            addsitedir(sitedir, known_paths)\n\n    return known_paths\n\ndef setBEGINLIBPATH():\n    \"\"\"The OS\/2 EMX port has optional extension modules that do double duty\n    as DLLs (and must use the .DLL file extension) for other extensions.\n    The library search path needs to be amended so these will be found\n    during module import.  Use BEGINLIBPATH so that these are at the start\n    of the library search path.\n\n    \"\"\"\n    dllpath = os.path.join(sys.prefix, \"Lib\", \"lib-dynload\")\n    libpath = os.environ['BEGINLIBPATH'].split(';')\n    if libpath[-1]:\n        libpath.append(dllpath)\n    else:\n        libpath[-1] = dllpath\n    os.environ['BEGINLIBPATH'] = ';'.join(libpath)\n\n\ndef setquit():\n    \"\"\"Define new builtins 'quit' and 'exit'.\n\n    These are objects which make the interpreter exit when called.\n    The repr of each object contains a hint at how it works.\n\n    \"\"\"\n    if os.sep == ':':\n        eof = 'Cmd-Q'\n    elif os.sep == '\\\\':\n        eof = 'Ctrl-Z plus Return'\n    else:\n        eof = 'Ctrl-D (i.e. EOF)'\n\n    class Quitter(object):\n        def __init__(self, name):\n            self.name = name\n        def __repr__(self):\n            return 'Use %s() or %s to exit' % (self.name, eof)\n        def __call__(self, code=None):\n            # Shells like IDLE catch the SystemExit, but listen when their\n            # stdin wrapper is closed.\n            try:\n                sys.stdin.close()\n            except:\n                pass\n            raise SystemExit(code)\n    __builtin__.quit = Quitter('quit')\n    __builtin__.exit = Quitter('exit')\n\n\nclass _Printer(object):\n    \"\"\"interactive prompt objects for printing the license text, a list of\n    contributors and the copyright notice.\"\"\"\n\n    MAXLINES = 23\n\n    def __init__(self, name, data, files=(), dirs=()):\n        self.__name = name\n        self.__data = data\n        self.__files = files\n        self.__dirs = dirs\n        self.__lines = None\n\n    def __setup(self):\n        if self.__lines:\n            return\n        data = None\n        for dir in self.__dirs:\n            for filename in self.__files:\n                filename = os.path.join(dir, filename)\n                try:\n                    fp = file(filename, \"rU\")\n                    data = fp.read()\n                    fp.close()\n                    break\n                except IOError:\n                    pass\n            if data:\n                break\n        if not data:\n            data = self.__data\n        self.__lines = data.split('\\n')\n        self.__linecnt = len(self.__lines)\n\n    def __repr__(self):\n        self.__setup()\n        if len(self.__lines) &lt;= self.MAXLINES:\n            return \"\\n\".join(self.__lines)\n        else:\n            return \"Type %s() to see the full %s text\" % ((self.__name,)*2)\n\n    def __call__(self):\n        self.__setup()\n        prompt = 'Hit Return for more, or q (and Return) to quit: '\n        lineno = 0\n        while 1:\n            try:\n                for i in range(lineno, lineno + self.MAXLINES):\n                    print self.__lines[i]\n            except IndexError:\n                break\n            else:\n                lineno += self.MAXLINES\n                key = None\n                while key is None:\n                    key = raw_input(prompt)\n                    if key not in ('', 'q'):\n                        key = None\n                if key == 'q':\n                    break\n\ndef setcopyright():\n    \"\"\"Set 'copyright' and 'credits' in __builtin__\"\"\"\n    __builtin__.copyright = _Printer(\"copyright\", sys.copyright)\n    if sys.platform[:4] == 'java':\n        __builtin__.credits = _Printer(\n            \"credits\",\n            \"Jython is maintained by the Jython developers (www.jython.org).\")\n    else:\n        __builtin__.credits = _Printer(\"credits\", \"\"\"\\\n    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n    for supporting Python development.  See www.python.org for more information.\"\"\")\n    here = os.path.dirname(os.__file__)\n    __builtin__.license = _Printer(\n        \"license\", \"See https:\/\/www.python.org\/psf\/license\/\",\n        [\"LICENSE.txt\", \"LICENSE\"],\n        [os.path.join(here, os.pardir), here, os.curdir])\n\n\nclass _Helper(object):\n    \"\"\"Define the builtin 'help'.\n    This is a wrapper around pydoc.help (with a twist).\n\n    \"\"\"\n\n    def __repr__(self):\n        return \"Type help() for interactive help, \" \\\n               \"or help(object) for help about object.\"\n    def __call__(self, *args, **kwds):\n        import pydoc\n        return pydoc.help(*args, **kwds)\n\ndef sethelper():\n    __builtin__.help = _Helper()\n\ndef aliasmbcs():\n    \"\"\"On Windows, some default encodings are not provided by Python,\n    while they are always available as \"mbcs\" in each locale. Make\n    them usable by aliasing to \"mbcs\" in such a case.\"\"\"\n    if sys.platform == 'win32':\n        import locale, codecs\n        enc = locale.getdefaultlocale()[1]\n        if enc.startswith('cp'):            # \"cp***\" ?\n            try:\n                codecs.lookup(enc)\n            except LookupError:\n                import encodings\n                encodings._cache[enc] = encodings._unknown\n                encodings.aliases.aliases[enc] = 'mbcs'\n\ndef setencoding():\n    \"\"\"Set the string encoding used by the Unicode implementation.  The\n    default is 'ascii', but if you're willing to experiment, you can\n    change this.\"\"\"\n    encoding = \"ascii\" # Default value set by _PyUnicode_Init()\n    if 0:\n        # Enable to support locale aware default string encodings.\n        import locale\n        loc = locale.getdefaultlocale()\n        if loc[1]:\n            encoding = loc[1]\n    if 0:\n        # Enable to switch off string to Unicode coercion and implicit\n        # Unicode to string conversion.\n        encoding = \"undefined\"\n    if encoding != \"ascii\":\n        # On Non-Unicode builds this will raise an AttributeError...\n        sys.setdefaultencoding(encoding) # Needs Python Unicode build !\n\n\ndef execsitecustomize():\n    \"\"\"Run custom site specific code, if available.\"\"\"\n    try:\n        import sitecustomize\n    except ImportError:\n        pass\n    except Exception:\n        if sys.flags.verbose:\n            sys.excepthook(*sys.exc_info())\n        else:\n            print &gt;&gt;sys.stderr, \\\n                \"'import sitecustomize' failed; use -v for traceback\"\n\n\ndef execusercustomize():\n    \"\"\"Run custom user specific code, if available.\"\"\"\n    try:\n        import usercustomize\n    except ImportError:\n        pass\n    except Exception:\n        if sys.flags.verbose:\n            sys.excepthook(*sys.exc_info())\n        else:\n            print&gt;&gt;sys.stderr, \\\n                \"'import usercustomize' failed; use -v for traceback\"\n\n\ndef main():\n    global ENABLE_USER_SITE\n\n    abs__file__()\n    known_paths = removeduppaths()\n    if ENABLE_USER_SITE is None:\n        ENABLE_USER_SITE = check_enableusersite()\n    known_paths = addusersitepackages(known_paths)\n    known_paths = addsitepackages(known_paths)\n    if sys.platform == 'os2emx':\n        setBEGINLIBPATH()\n    setquit()\n    setcopyright()\n    sethelper()\n    aliasmbcs()\n    setencoding()\n    execsitecustomize()\n    if ENABLE_USER_SITE:\n        execusercustomize()\n    # Remove sys.setdefaultencoding() so that users cannot change the\n    # encoding after initialization.  The test for presence is needed when\n    # this module is run as a script, because this code is executed twice.\n    if hasattr(sys, \"setdefaultencoding\"):\n        del sys.setdefaultencoding\n\nmain()\n\ndef _script():\n    help = \"\"\"\\\n    %s [--user-base] [--user-site]\n\n    Without arguments print some useful information\n    With arguments print the value of USER_BASE and\/or USER_SITE separated\n    by '%s'.\n\n    Exit codes with --user-base or --user-site:\n      0 - user site directory is enabled\n      1 - user site directory is disabled by user\n      2 - uses site directory is disabled by super user\n          or for security reasons\n     &gt;2 - unknown error\n    \"\"\"\n    args = sys.argv[1:]\n    if not args:\n        print \"sys.path = [\"\n        for dir in sys.path:\n            print \"    %r,\" % (dir,)\n        print \"]\"\n        print \"USER_BASE: %r (%s)\" % (USER_BASE,\n            \"exists\" if os.path.isdir(USER_BASE) else \"doesn't exist\")\n        print \"USER_SITE: %r (%s)\" % (USER_SITE,\n            \"exists\" if os.path.isdir(USER_SITE) else \"doesn't exist\")\n        print \"ENABLE_USER_SITE: %r\" %  ENABLE_USER_SITE\n        sys.exit(0)\n\n    buffer = []\n    if '--user-base' in args:\n        buffer.append(USER_BASE)\n    if '--user-site' in args:\n        buffer.append(USER_SITE)\n\n    if buffer:\n        print os.pathsep.join(buffer)\n        if ENABLE_USER_SITE:\n            sys.exit(0)\n        elif ENABLE_USER_SITE is False:\n            sys.exit(1)\n        elif ENABLE_USER_SITE is None:\n            sys.exit(2)\n        else:\n            sys.exit(3)\n    else:\n        import textwrap\n        print textwrap.dedent(help % (sys.argv[0], os.pathsep))\n        sys.exit(10)\n\nif __name__ == '__main__':\n    _script()<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u5728\u7528Python\u5904\u7406\u4e2d\u6587\u5b57\u7b26\u4e32\u65f6\uff0c\u62a5\u51fa\u4e86\u5982\u4e0b\u9519\u8bef\uff1a UnicodeDecodeError: &#8216;ascii&#8217; codec can&#8217;t decode byte 0xe9 in position 0: ordinal not in range(128) &nbsp; 1\u3001\u539f\u56e0 \u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cPython\u91c7\u7528\u7684\u662fascii\u7f16\u7801\u65b9\u5f0f\uff0c\u5982\u4e0b\u6240\u793a\uff1a \u25c4\u25ba python [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=427"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/427\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}