Python 是否有人知道如何修复此错误

Python 是否有人知道如何修复此错误,python,Python,我正在尝试为我的项目运行此代码,但在try语句中出现了一个错误,即unindent与任何外部缩进级别都不匹配 from apiclient.discovery import build from apiclient.errors import HttpError from oauth2client.tools import argparser DEVELOPER_KEY = "Replaced_my_API_key" YOUTUBE_API_SERVICE_NAME = "youtube" Y

我正在尝试为我的项目运行此代码,但在try语句中出现了一个错误,即unindent与任何外部缩进级别都不匹配

from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.tools import argparser

DEVELOPER_KEY = "Replaced_my_API_key"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"

def youtube_search(options):
  youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,
    developerKey=DEVELOPER_KEY)


  search_response = youtube.search().list(
    q=options.q,
    part="id,snippet",
    maxResults=options.max_results
  ).execute()

  videos = []
  channels = []
  playlists = []

  for search_result in search_response.get("items", []):
    if search_result["id"]["kind"] == "youtube#video":
      videos.append("%s (%s)" % (search_result["snippet"]["title"],
                                 search_result["id"]["videoId"]))
    elif search_result["id"]["kind"] == "youtube#channel":
      channels.append("%s (%s)" % (search_result["snippet"]["title"],
                                   search_result["id"]["channelId"]))
    elif search_result["id"]["kind"] == "youtube#playlist":
      playlists.append("%s (%s)" % (search_result["snippet"]["title"],
                                    search_result["id"]["playlistId"]))

  print ("Videos:\n", "\n".join(videos), "\n")
  print ("Channels:\n", "\n".join(channels), "\n")
  print ("Playlists:\n", "\n".join(playlists), "\n")


if __name__ == "__main__":
    to_search = "Witcher 3"
    argparser.add_argument("--q", help="Search term", default=to_search)
    argparser.add_argument("--max-results", help="Max results", 
default=25)
    args = argparser.parse_args()

  **From the following statement the code is giving an error**
i、 不一致误差 尝试: youtube_搜索参数 除HttpError外,e:
打印HTTP错误%d发生:\n%s%e.resp.status,e.content

如果您将idendation与空格和制表符混合使用,则此错误很常见。选择一个并坚持下去。您可以尝试两件事:

为编辑器中的空白着色。在vim中,您可以使用:set list执行此操作。找出有问题的行并纠正它。 在shebang:中为Python提供选项-tt/usr/bin/python-tt。当您在同一文件中混合标识时,这会给您额外的警告。
“未缩进”与任何外部缩进级别都不匹配-错误是不言自明的。请检查缩进并修复它。Python对此相当认真