내 컴퓨터 (Windows 7)의 지정된 경로에서 파일을 만들려고하지만 해당 경로에서 파일이 만들어지지 않습니다. 그것은 시간 코드가 실행될 때까지 컴파일러에서 사실상 생성되지만 OS에서는 생성되지 않습니다.Windows OS에서 파일 쓰기 권한 받기
x = str(input("Please enter the file name: "))
x = 'C:\Users\Aakash\Documents\Aakash\Aakash College\Practical\MIT Paython\\'+x
f = open('x','w')
print 'Please choose your option:'
print '1.Write'
print '2.Read'
choice = int(input('Enter the number: '))
while choice==1:
text = input('Please enter the string: ')
f.write(text)
f.write('\n')
print 'Please choose your option:'
print '1.Write'
print '2.Read'
choice = int(input('Enter the number: '))
if choice==2:
f.close()
print
f = open('x','r')
text = f.readline()
print text
while text!='':
text = f.readline()
print text
f.close()
나는 창문이 파일을 만들 권한을 부여하지 않는다고 생각합니다. 그렇다면 주어진 위치에 실제 파일을 생성 할 수있는 권한을 얻는 방법은 무엇입니까?
동일한 코드를 IDLE로 시도하는 동안 작동하지만 새로운 파일 (모듈을 생성하여)에서 시도하면 작동하지 않습니다! (예 : 모듈이 오류없이 올바르게 실행되지만 실제 파일을 만들지 않음)
참고 : 파일은 관리자 계정에서 실행됩니다. 그리고 그는 모든 디렉토리에 액세스 할 수있는 권한을 가지고 있습니다.
모듈을 어떻게 만들고 실행합니까? – Blender
'x'라는 파일을 열려고합니다. – Matthias
'f = open (x, 'w') 시도해주세요. – martineau