这两个我都有。如果我能修好一个,另一个就会出现
这将获得引号的未定义/未使用变量错误
import random
def primary():
print("Keep it logically awesome.")
f = open("quotes.txt")
quotes = f.readlines()
f.close()
last = len (quotes) - 1
rnd = random.randint(0, last)
print(quotes[rnd])
if __name__== "__main__":
primary()
如果我只是从print (quotes[rnd])
中删除所有空格,那么我会得到“意外缩进”
正确的代码如下所示
你必须在几个地方集中精力
编写单行if语句的另一种方法是
有关缩进的更多信息,请参阅: https://docs.python.org/3/reference/lexical_analysis.html#indentation
https://www.geeksforgeeks.org/indentation-in-python/amp/
https://www.w3schools.com/python/gloss_python_indentation.asp
希望这对你有帮助。享受吧
相关问题 更多 >
编程相关推荐