python 3.5-PermissionError:[Errno 13]在visual studio 2015中拒绝了权限

python 3.5-PermissionError:[Errno 13]在visual studio 2015中拒绝了权限,python,visual-studio,Python,Visual Studio,在我的代码中,我试图使用append打开一个文件,以检查该文件是否存在以及里面有什么 def setFile(): # Create file if it does not exist openingFile = open('talents.txt', 'a') openingFile.close() # Read file openingFile = open('talents.txt', 'r') read = openingFile.read() # Check for nothin

在我的代码中,我试图使用append打开一个文件,以检查该文件是否存在以及里面有什么

def setFile():

# Create file if it does not exist
openingFile = open('talents.txt', 'a')
openingFile.close()

# Read file
openingFile = open('talents.txt', 'r')
read = openingFile.read()

# Check for nothing
if read == '':
    openingFile.close()
    openingFile = open('talents.txt', 'w')
    openingFile.write("100")

# Check for 0
if read == '0':
    openingFile.close()
    openingFile = open('talents.txt', 'w')
    openingFile.write("100")
当我在cmd和linux机器上运行它时,它运行得非常好,但在Visual Studio 2015中,当试图在append中打开文件时,它抛出一个被拒绝的权限。我该如何解决这个问题

另外,我真的不想用r+