繁体   English   中英

如何比较 input() 和 .readline()?

[英]How can I comparing input() and .readline()?

userInputfcon中的字符串fcon匹配,但仍然无法打印“匹配”消息。

我试过比较input()两个字符串,它起作用了。

userInput = input("First String")

with open("file1", mode ="r") as nameDb:
    fcon = nameDb.readline()

print(type(fcon),fcon)
print(type(userInput), userInput)


if userInput is fcon:
    print("Matched")
else:
    print("No match")


试试吧,

userInput = input("First String: ")

with open("file1.txt", "r") as nameDb:
    fcon = nameDb.readline()

if userInput == fcon:
    print("Matched")
else:
    print("NO match")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM