Python 3.x SyntaxError:(unicode错误)'UnicodeScape'编解码器无法解码位置292-293中的字节:在导入期间截断\UXXXXXXXX转义

Python 3.x SyntaxError:(unicode错误)'UnicodeScape'编解码器无法解码位置292-293中的字节:在导入期间截断\UXXXXXXXX转义,python-3.x,unicode,Python 3.x,Unicode,代码: 结果: import os import random import time import requests from appetizer import Appetizer 76开胃菜.py文件中的行: Traceback (most recent call last): File "C:/GITHUB/stress_testing/main.py", line 5, in <module> from appetizer import Appetize

代码:

结果:

import os
import random
import time
import requests
from appetizer import Appetizer
76开胃菜.py文件中的行:

    Traceback (most recent call last):
  File "C:/GITHUB/stress_testing/main.py", line 5, in <module>
    from appetizer import Appetizer
  File "C:\GITHUB\stress_testing\venv\lib\site-packages\appetizer\__init__.py", line 17, in <module>
    from .appetizer import Appetizer
  File "C:\GITHUB\stress_testing\venv\lib\site-packages\appetizer\appetizer.py", line 76
            """
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 292-293: truncated \UXXXXXXXX escape
我知道Windows路径中的\double\等等。但在我做一些事情之前,这里有一个错误——在导入阶段。我应该换什么?在哪里?
我试过使用virtual env和common。

它实际上会告诉您出了什么问题。代码第76行函数定义中的位置292-293处有一个\uxxxx转义字符长度无效

以下工作将起作用:

 def detect_adb(self):
        """ Detect the path to the adb tool from the Android SDK

        :return: A JSON object. For example: {'adb': '/home/myuser/Android/Sdk/platform-tools/adb'}

        Note that the path could be a unicode string.
        The default installation paths for different OSes are:
        Windows: C:\Users\<User Name>\AppData\Local\Android\sdk\platform-tools\
        Linux: /home/<User Name>/Android/Sdk/platform-tools/adb
        """
        return json.loads(self.appetizer.check_output(["adb", "detectadb"]))
鉴于:

stri = """ Detect the path to the adb tool from the Android SDK

    :return: A JSON object. For example: {'adb': '/home/myuser/Android/Sdk/platform-tools/adb'}

    Note that the path could be a unicode string.
    The default installation paths for different OSes are:
    Windows: C:\\Users\<User Name>\AppData\Local\Android\sdk\platform-tools\
    Linux: /home/<User Name>/Android/Sdk/platform-tools/adb
    """
stri[292] #'\\'
stri[293] #'U'
这种行为的原因是,请指出下次编写的相关包是为Python2.7编写的,其中“\U”将顺利通过。您必须检查源代码,并手动将这些序列替换为双反斜杠或正斜杠

stri = """ Detect the path to the adb tool from the Android SDK

    :return: A JSON object. For example: {'adb': '/home/myuser/Android/Sdk/platform-tools/adb'}

    Note that the path could be a unicode string.
    The default installation paths for different OSes are:
    Windows: C:\Users\<User Name>\AppData\Local\Android\sdk\platform-tools\
    Linux: /home/<User Name>/Android/Sdk/platform-tools/adb
    """
#SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 292-293: truncated \UXXXXXXXX escape