Skip to main content
 首页 » 编程设计

python之如何阻止 a\from 关闭一个字符串

2025年05月04日49傻小

<分区>

我需要在一个文件夹中打开一个文件,这应该可以工作,但是\会导致字符串关闭,所以 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