我有一个程序要求用户输入一个问题,程序然后回答它.我想知道的是如何限制用户输入变量的字母数量.
我需要在一个文件夹中打开一个文件,这应该可以,但是\会导致字符串关闭,所以Me变量是绿色的,不应该是我.我该如何修复它,我需要能够阻止\关闭字符串或直接进入文件夹而不使用\符号.我使用的变量大多数似乎都是随机的,这是因为我不希望它与真正的函数类似,让它混淆了让我或其他人感到困惑.
Me = Jacob #Variable me with Jacob in it
def God():#creates function called god
File = open ("Test\" + Me + ".txt","r")#opens the Jacob file in the test folder.
Door = ""#creates door variable
Door = File.read().splitlines()#sets what is in Jacob file to be in Door variable
print (Door)#prints the varible door
God()#does go function
Run Code Online (Sandbox Code Playgroud)