Answer the question
In order to leave comments, you need to log in
TypeError: 'NoneType' object cannot be interpreted as an integer how to fix?
There is such a code
import os
import time
krik = os.startfile(r'звуки\крик.mp3')
time.sleep(5)
os.close(krik)
TypeError: 'NoneType' object cannot be interpreted as an integer
Answer the question
In order to leave comments, you need to log in
I think it returns None, so the variable krik contains None, so when this None is input to os.close(), you get an error.
I would recommend that you first study the python object model so that you understand exactly what you are doing. Secondly, study the documentation regarding the libraries and methods used. In general, this is easy to do by issuing the
and command.
In particular, the os.close() method requires a file descriptor as input, i.e. number, int. So, you need to get the descriptor and feed it to the method.
Ps Well, by the way, as the respected Vindicar pointed out, os.close does not close the running process. It is necessary to dig in the direction of the kill command, I think so. os.startfile(r'звуки\крик.mp3')
help(os.close)
startfile() returns as soon as the associated application is launched. There is no option to wait for the application to close, and no way to retrieve the application's exit status.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question