Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想回到“我的生活”;输入“;在python中键入错误字符后_Python_If Statement_Input - Fatal编程技术网

我想回到“我的生活”;输入“;在python中键入错误字符后

我想回到“我的生活”;输入“;在python中键入错误字符后,python,if-statement,input,Python,If Statement,Input,我想在用户键入另一个不是“n”字符串的字符后返回“input”, 输入数据是一个“输入”,它使用户按enter键继续或键入“n”,但如果用户键入另一个字符串,控制台将关闭 您可以使用while循环: >>> user_input = '' >>> while user_input != 'n': ... user_input = input("Enter your input: ") ... Enter your input: a

我想在用户键入另一个不是“n”字符串的字符后返回“input”, 输入数据是一个“输入”,它使用户按enter键继续或键入“n”,但如果用户键入另一个字符串,控制台将关闭


您可以使用while循环:

>>> user_input = ''
>>> while user_input != 'n':
...     user_input = input("Enter your input: ")
...
Enter your input: a
Enter your input: 1
Enter your input: 3
Enter your input: n
>>>

您应该使用这样的while循环来完成

_WriteList = input("Write a textfile with the file list? (Enter) Yes or (n) No: ")

while _WriteList != 'n':
  sevenZipListWrite()
  _WriteList = input("Write a textfile with the file list? (Enter) Yes or (n) No: ")

sevenZipList()

请在下一次发布之前尝试做一些研究。
_WriteList = input("Write a textfile with the file list? (Enter) Yes or (n) No: ")

while _WriteList != 'n':
  sevenZipListWrite()
  _WriteList = input("Write a textfile with the file list? (Enter) Yes or (n) No: ")

sevenZipList()