【问题标题】:invalid url giving regexmatcherror and not raising error when invalid url is given in pytube program无效的 url 给出 regexmatcherror 并且在 pytube 程序中给出无效的 url 时不会引发错误
【发布时间】:2020-05-16 20:38:19
【问题描述】:
try:
    link = input("Enter URL of video you would like to download") 
except RegexMatchError:
    print("error")

我正在使用 Pytube 下载 youtube 视频,但我已经完成了所有工作,但我想在给出无效 URL 或输入时引发错误。每当我输入无效输入时,我都会在控制台中看到 RegexMatchError,但我没有看到我的错误消息,只是 Pycharm 给我的错误消息。

【问题讨论】:

    标签: python error-handling pytube


    【解决方案1】:

    尝试更改错误类型,如:

    try:
        link = input("Enter URL of video you would like to download") 
    except Exception:
        print("error")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-26
      • 2015-03-08
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      • 2015-11-06
      • 1970-01-01
      相关资源
      最近更新 更多