我正在编写脚本读取用户的路径,当我使用input()
和raw_input()
从用户获取角色时
choice = raw_input()
if choice[0] is 'y' or 'Y':
print ("text")
else:
print ("another text")
并按 y 或任何键,控制台在if条件中显示 text 。
我将choice[0]
更改为choice
,问题仍然存在。
答案 0 :(得分:0)
试试这个: -
choice = input()
if choice[0] == 'y' or choice[0] == 'Y':
print('text')
else:
print('another text')
我使用的是python 3.6.1,它对我有用。它可能对你有所帮助。 raw_input()在更高版本3中重命名为input()。