【问题标题】:I need some help getting my python script to work我需要一些帮助才能让我的 python 脚本正常工作
【发布时间】:2019-03-15 11:47:44
【问题描述】:

我需要一些帮助才能让我的 python 脚本同时在 python2 和 python3 上运行。 在 python3 中,当我运行脚本并到达您选择 ITAG 的部分时,它说:

From the lists above, find the ITAG number of the format you want to convert the video to.
Type the ITAG number here: 
Traceback (most recent call last):
  File "/home/MrMcTiller/autopytubev2_working.py", line 299, in <module>
    Type the ITAG number here: """))
ValueError: could not convert string to float: 
>>> 

Here is a link to my python script.

【问题讨论】:

  • 这个问题太模糊了。要改进它,您需要提出具体问题。
  • @JackAidley,我更新了问题。
  • 创建标题时,请尝试描述您遇到的问题,而不是您遇到问题的事实。
  • 感谢您的更新,由于您遇到特定问题,我已投票支持重新打开,但可以通过将产生问题的特定代码部分引入问题来改进问题,并且最好创建显示问题的最小完整示例(请参阅stackoverflow.com/help/mcve 寻求帮助)。
  • 简而言之:我们需要您的代码,在这里。 (并非全部,在外部链接中。这就是minimal reproducible example 所指的内容。)

标签: python python-3.x python-2.7


【解决方案1】:

您似乎正在尝试将空字符串转换为浮点数。在 Python3 中,float('') 会产生您描述的错误,并且如果用户通过简单地按回车来响应输入提示就会发生。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    相关资源
    最近更新 更多