python无法更改开始视频

时间:2015-02-02 13:16:56

标签: python

我想通过输入yes或no来更改打开链接。 但我尝试了一切没有成功的事情

input3 = input ("3. " + input_name + " ik heb een liedje wil je hem horen: ")
import webbrowser
if ("input_3 = ja")
webbrowser.open (' https://www.youtube.com/watch?v=oLaOsNwmieE ')

1 个答案:

答案 0 :(得分:3)

input3 = input ("3. " + input_name + " ik heb een liedje wil je hem horen: ")
import webbrowser
if input_3 == "ja":
    webbrowser.open (' https://www.youtube.com/watch?v=oLaOsNwmieE ')

您的输入返回一个字符串,因此您的缩进错误。正确的一个是==而不是=,如果你像"input3"那样编写它,Python会看到一个常规字符串。但它是你定义的一个变量而且你不需要parantheses。

"input_3 == ja" #this is a regular string like "Hello"
 input_3 == "ja" #this checks the condition. If input_3 equals to 'ja'.

引号会更改所有内容,请记住"4"4不同。