gpt4 book ai didi

python - 强制 raw_input

转载 作者:太空宇宙 更新时间:2023-11-03 12:12:54 26 4
gpt4 key购买 nike

我将如何实现以下内容:

title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))
if not title:
# repeat raw_input

最佳答案

title_selection = ''
while not title_selection:
title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))

需要事先定义title_selection'',即为空(也为False)。not 将使 False 变为 True(否定)。

关于python - 强制 raw_input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10289477/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com