Python Don';我不理解这段代码的正确/错误部分。我在这段代码中的输入(所有整数)怎么可能;“要真实”;或;是假的吗;? print(“请输入整数(然后按enter键两次以显示完成):”) s=input()#打印后输入的任何内容 first=True#这是什么意思??? 而s!=“”这是什么意思??? lst=s.split()#将所有输入拆分为一个列表 对于lst中的x: 如果第一个:#如果它在你的第一个? maxV=int(x)#那么最大值将作为整数输入 first=False#这是什么意思? 其他: 如果maxV

Python Don';我不理解这段代码的正确/错误部分。我在这段代码中的输入(所有整数)怎么可能;“要真实”;或;是假的吗;? print(“请输入整数(然后按enter键两次以显示完成):”) s=input()#打印后输入的任何内容 first=True#这是什么意思??? 而s!=“”这是什么意思??? lst=s.split()#将所有输入拆分为一个列表 对于lst中的x: 如果第一个:#如果它在你的第一个? maxV=int(x)#那么最大值将作为整数输入 first=False#这是什么意思? 其他: 如果maxV,python,Python,我对这段代码中的first=True和first=False感到困惑,设置它意味着什么 等于真或假的变量?也不清楚什么是whiles!=“”:意思是。很抱歉 我是一个完全的初学者,如果有人能帮助我,我将永远感激 print("Please enter integers (then press enter key twice to show you're done):") s = input() #whatever you're inputting after t

我对这段代码中的first=True和first=False感到困惑,设置它意味着什么 等于真或假的变量?也不清楚什么是whiles!=“”:意思是。很抱歉 我是一个完全的初学者,如果有人能帮助我,我将永远感激

print("Please enter integers (then press enter key twice to show you're done):")
s = input()                  #whatever you're inputting after the print
first = True                 #What does this mean???
while s != "":               #What does this mean???
    lst = s.split()          #split all your inputs into a list
    for x in lst:
        if first:                            #If its in ur lst?
            maxV = int(x)           #then the max value will be that input as an integer
            first = False                #What does this mean?
        else:
            if maxV < int(x):
                maxV = int(x)
    s= input()
print(maxV)
将布尔变量设置为
True

first = True                 
检查输入是否为空<代码>=表示不相等,与表示相等的
=
相反

while s != "":
如果
first
变量为
True
则运行if语句的代码。在这种情况下,将该值设置为最大值,然后

if first:

first
设置为
False
,因为下一个值不再是第一个值了

我真的不知道这是什么编程语言,但根据基本知识,我可以告诉您这些东西的含义。我希望这有助于:

first = False
print(“请输入整数(然后按enter键两次以显示完成):”)
s=input()#这里s成为您的输入
first=True#这里您将first设置为布尔值,其状态可以为True或false。在本例中,它获得赋值为True的值
而s!=“”:#While重复某个进程,在本例中,它会在s不为空时保持该进程继续

lst=s.split()#将所有输入拆分成一个列表这应该是什么语言?它当然不是Java,那么为什么要把它标记为Java呢?这些都是非常基本的问题,这些问题有一个地方可以回答:这看起来像python,所以我冒昧地猜测一下,你想知道带布尔值的if语句的语法:这真的很有帮助,非常感谢。虽然我仍然对第6行和第7行有点困惑。您正在检查列表中的x(如果我的不同输入)是否在第一位(是真还是假)。整数(假设我输入3、4、47、62等)如何为真或假?我知道for函数是一个循环,所以它要遍历每个输入(lst中的x)——并检查它是否是“第一个”。如果我的整数是“第一个”,这到底意味着什么?如果我的x在lst中是“真”还是“假”,这意味着什么?如果这让人困惑的话,很抱歉!或者它只是自动地“first”(也称为true),因为您之前在first=true中设置了它,而一旦设置first=false,它就不再是这种情况了?@DianaA
for x in lst
就是您所说的for循环。它遍历下面的代码,并对每个循环向上计数1,直到
x
达到
之后列表大小的值。例如,如果我对范围(0,5)内的x说
,下面的代码将执行5次。希望这能有所帮助。@THess“它会遍历下面的代码,并对每个循环向上计数1,直到x达到in之后列表大小的值。”它不会。它遍历列表对象中的每个值,而不是0->len(列表对象)。Python for循环类似于基于迭代器的Java for each循环。
print("Please enter integers (then press enter key twice to show you're done):")
s = input()                  #Here s becomes your input
first = True                 #Here you set first as a boolean which can have the state true or false. In this example it gets the value True assigned
while s != "":               #While repeats a certain process and in this example it keeps this process going while s isn't empty
    lst = s.split()          #splits all your inputs into a list <- you got that right
    for x in lst:
        if first:                        #It checks if first is true. If it is true it keeps going with the code right after the if
            maxV = int(x)                #then the max value will be that input as an integer
            first = False                #this sets a new value to first. which is false in this case
        else:
            if maxV < int(x):
                maxV = int(x)
    s= input()
print(maxV)