因此,我目前正在学习代码,我目前正在做一些小型/初学者项目,以熟悉python语言。
通常我可以通过寻找我想要的东西。。。
但这次我被卡住了。
我想做的对你们大多数人来说非常简单。。。
我想开一家店。txt文件(文件创建代码已准备就绪)读取文件的特定行。txt并将其分配给一个变量,该变量稍后用于与另一个用户输入变量进行比较。。。
抱歉,如果不是很清楚。
所以这就是我要说的。。。
with open('infos.txt', 'r') as f:
lines = f.readlines()
user_master = lines[0]
print(user_master) # this gives the output that i want: "test"
if user_master == "test":
print("OK") # This does not work, no output on the console...