0
Why is this code searching for the file instead of creating it?
import os, re f = open("newFile.txt", "w+") pathName = os.path.abspath(f.name) pattern = r"\\" count = list(x.start() for x in re.finditer(pattern, pathName)) os.remove(pathName) #HERE f = open("C:\\Users\\" + pathName[count[1]+1:count[2]-1] + "\\Desktop\\newFile.txt", "w+")
2 Antworten
+ 1
Your query is not clear from your code. Could you please explain more?
+ 1
I fixed it nvm