0
The program should create a mes/dia.dat file, but nothing is created and this error is returned to me, where we can see that the file is not being created with the file.open() command. Follow the code of the program. I found in the stack something about the program not recognizing the directory in which I am running the program, however, even after adding "import os", there are no results.
import os
ch=1
while ch != 0:
print("### Script rodando. Bem-vindo a inserção de dados. ####\n\n")
m = int(input('Insira o mes:'))
d = int(input('Insira o dia:'))
name = '{}/{}'.format(m,d)
curpath = os.path.abspath(os.curdir)
#abrir o mes/dia.dat aqui
file = open("%s.txt" %name, "w+")
qt = int(input('Insira a quantidade de alunos presentes.'))
for i in range(0,qt):
nome = raw_input('Insira o nome do aluno:')
course = raw_input('Insira o curso:')
data = '{} {}'.format(nome,course)
file.write(data)
file.close()
ch = int(input('Fim das opções.\nInsira 0 para fechar ou 1 para inserir dados em outro arquivo:'))
First of all in the file, put
print "programa iniciado com sucesso"
and post the return.– MagicHat
Are you using python2 or 3?
– Tmilitino
I am using python2
– Victor Barboza
He may be searching in the root directory as the answer below says, or actually understanding the "/" that separates month and day as one directory within another
– Absolver