我正在编写一个小程序,当我运行它时,我得到一个 None。下面是一个例子:
print('Welcome to CTFTOOL')
print('Created by P.R.B.')
print('Choose your option:')
inp1 = input(print('''
1)Auto Caesar Chiper.
2)Binary-Decimal & Decimal-Binary.'''))
在第四次打印后我得到一个无,并且每次打印都要求输入。
if inp1 == '1':
text1 = input(print('Input the text you want to decode:\n'))
autocaesarchiper(text1)
在 autocaesarchipher() 函数运行之前,我得到了另一个 None。 我一直在寻找另一个运行良好的代码,但我还没有看到问题所在。 谢谢:)
请您参考如下方法:
input()在接受输入之前进行论证并打印出来。
none 是您在 print() 函数触发后看到的。在 python 中,如果你的函数不返回任何东西并且完成它默认返回 None 。例如:
print(print())
输出:
#new line
None
要修复您的代码,只需执行以下操作:
text1 = input('Input the text you want to decode:\n')
