def confirm_choice():
confirm = input("[c]Confirm or [v]Void: ")
if confirm != 'c' and confirm != 'v':
print("\n Invalid Option. Please Enter a Valid Option.")
confirm_choice()
print (confirm)
return confirm
Run Code Online (Sandbox Code Playgroud)
例如,当键入无效输入时,字母“k”后跟有效输入“c”,该函数将打印输入“c”和“k”
输出:
c
k
Run Code Online (Sandbox Code Playgroud)
如何更改上述程序,使其仅返回“c”或“v”,并在输入无效时重复该函数。
每当我尝试使用apt-get install安装软件包时,我都会遇到以下错误:
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-support (1.0.15) ...
File "/usr/sbin/update-python-modules", line 52
print x
^
SyntaxError: Missing parentheses in call to 'print'
dpkg: error processing package python-support (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up mercurial-common (3.1.2-2+deb8u1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", …Run Code Online (Sandbox Code Playgroud)