【发布时间】:2019-05-28 12:28:26
【问题描述】:
无论用户输入什么,我都会得到相同的输出。我正在处理的主要 python 文件来自辅助文件中的函数调用。
我已尝试更改 if else 语句条件,但仍然遇到同样的问题。
if __name__ == '__main__':
import No_2
No_2.cont()
print('File1: This would be a good place to continue data manipulation.')
input("Press the enter key to close")
这里是 No_2
def cont():
import sys
c = input('File2: Would you like to continue? ')
if c == 'Y' or 'y':
print('File2: Ok we\'ll carry on...')
print(' ')
return
else: sys.exit()
我希望脚本在 C 不 = Y 或 y 时关闭... 如果输入是 Y 或 y,我希望它返回到主脚本。
【问题讨论】:
-
if c == 'Y' or c == 'y',或者写成c.lower() == 'y'
标签: python python-3.x function if-statement user-defined-functions