英文:
How to assign drive links with loop in colab
问题
我想在一个循环中分配这些链接。但我不知道要使用什么。
我尝试了字典,但我做不到。
from google.colab import drive
drive.mount('/content/drive')
video_1 = "/content/drive/MyDrive/outputs_1"
video_2 = "/content/drive/MyDrive/outputs_2"
video_3 = "/content/drive/MyDrive/outputs_3"
video_4 = "/content/drive/MyDrive/outputs_4"
video_5 = "/content/drive/MyDrive/outputs_5"
video_6 = "/content/drive/MyDrive/outputs_6"
video_7 = "/content/drive/MyDrive/outputs_7"
video_8 = "/content/drive/MyDrive/outputs_8"
video_9 = "/content/drive/MyDrive/outputs_9"
video_10 = "/content/drive/MyDrive/outputs_10"
video_11 = "/content/drive/MyDrive/outputs_11"
video_12 = "/content/drive/MyDrive/outputs_12"
英文:
I want to assign these links in a loop. But I don't know what to use.
I tried dictionary but i couldn't do it
from google.colab import drive
drive.mount('/content/drive')
video_1 = "/content/drive/MyDrive/outputs_1"
video_2 = "/content/drive/MyDrive/outputs_2"
video_3 = "/content/drive/MyDrive/outputs_3"
video_4 = "/content/drive/MyDrive/outputs_4"
video_5 = "/content/drive/MyDrive/outputs_5"
video_6 = "/content/drive/MyDrive/outputs_6"
video_7 = "/content/drive/MyDrive/outputs_7"
video_8 = "/content/drive/MyDrive/outputs_8"
video_9 = "/content/drive/MyDrive/outputs_9"
video_10 = "/content/drive/MyDrive/outputs_10"
video_11 = "/content/drive/MyDrive/outputs_11"
video_12 = "/content/drive/MyDrive/outputs_12"
答案1
得分: 0
如果列表对您有用,您可以这样做:
from google.colab import drive
drive.mount('/content/drive')
video_list = ["/content/drive/MyDrive/outputs_" + str(i) for i in range(1, 13)]
如果您需要关于列表理解的帮助:
[查看这个!][1]
[1]: https://www.w3schools.com/python/python_lists_comprehension.asp
英文:
If a list works for you, you could do this:
from google.colab import drive
drive.mount('/content/drive')
video_list = ["/content/drive/MyDrive/outputs_" + str(i) for i in range(1, 13)]
If you need help regarding list comprehension:
Check this out!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论