小编lui*_*jie的帖子

在 python 中创建确认函数

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”,并在输入无效时重复该函数。

python function python-2.7 python-3.x

3
推荐指数
1
解决办法
7406
查看次数

无法apt-get安装包E:子进程/ usr/bin/dpkg返回错误代码(1)

每当我尝试使用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)

python linux mercurial debian python-3.x

1
推荐指数
1
解决办法
1647
查看次数

标签 统计

python ×2

python-3.x ×2

debian ×1

function ×1

linux ×1

mercurial ×1

python-2.7 ×1