You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python编写输入生成密码程序输出不符合要求如何解决

问题原因

  • 自动判分系统会收集程序所有标准输出内容做校验,input()函数携带的提示文本也会被算作输出内容,原代码的输入提示串打乱了系统预期的输出结构,导致无法识别到目标输出行。

修改方案

删除input()函数内的提示文本即可,原有业务逻辑完全符合需求,无需调整。修改后代码如下:

def userdetails():
    words = input()
    word2 = input()
    numm = input()

    pw1 = words+"_"+word2
    pw2 = numm+words+numm

    print("You entered: {} {} {}" .format(words,word2,numm)) 

    print("First password:",pw1)
    print("Second password:",pw2)

    print("Number of characters in",pw1,":",len(pw1))
    print("Number of characters in",pw2,":",len(pw2))

userdetails()

输出验证

按顺序输入yellow、Daisy、6时,程序输出如下,完全匹配判分要求:

You entered: yellow Daisy 6
First password: yellow_Daisy
Second password: 6yellow6
Number of characters in yellow_Daisy : 12
Number of characters in 6yellow6 : 8

内容的提问来源于stack exchange,提问作者LycanSmoke4207

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 23:15:03