我有办法从列表中删除['']字符

时间:2017-10-14 21:37:13

标签: python windows youtube

我想创建一个生成youtube链接并打开网站的youtube视频生成器但我的问题是我追加的列表有这些['']字符和链接看起来像这样:https://www.youtube.com/watch?v=['u', 'q', 'W', 'S', 'A', 'v']

如何删除这些?

import webbrowser
import time
from random import randint
def removeNonAscii(s): return "".join(i for i in s if ord(i)<126 and ord(i)>31)
new = 2
genchar = 5
db = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
array = []

print("---Random-Youtube-Video---bye-Toasty---")
timesopen = int(input("Wie viele Seiten wollen sie öffnen (es wird nicht viele Treffer geben)? : "))

while (timesopen > 0):
    genchar = 5
    while (genchar >= 0):
        ran = randint(0,51)
        array.append(db[ran])
        genchar = genchar - 1
    url = "https://www.youtube.com/watch?v=" + str(array)
    print(url)
    webbrowser.open(url,new=new)
    timesopen = timesopen - 1

0 个答案:

没有答案