from google.colab import files
filename= os.listdir('/content/Real-ESRGAN/results')
files.download('/content/Real-ESRGAN/results/'+filename[0])
Showing this error msg
IndexError Traceback (most recent call last)
<ipython-input-5-9cd613c11ac6> in <module>()
4
5 filename= os.listdir('/content/Real-ESRGAN/results')
----> 6 files.download('/content/Real-ESRGAN/results/'+filename[0])
IndexError: list index out of range
What is likely happening is that your filename
list is empty. Thus, it has no element at index 0, so your index is out of range.
this code works perfectly:
for i in os.listdir('/content/youfolder') :
#print(i)
files.download('/content/youfolder/'+i)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.