有什么问题,大家可以相互交流
对于url = "https://baike.baidu.com/live/home/app/e23dedd8djo9dnerlalopsr3503823jkdelso9020994949.ts"后面的长度大于32位进行截取到32位,小于32位直接输出url的小程序。
def surl(url):
u1 = url.split("/")
u2 = u1[-1]
u3 = u2.split(".")
u4 = u3[0]
if len(u4) > 32:
u4 = u4[:32]
u3[0] = u4
u5 = ".".join(u3)
u1[-1] = u5
url = "/".join(u1)
return (url)
url = "https://baike.baidu.com/live/home/app/e23dedd8djo9dnerlalopsr3503823jkdelso9020994949.ts"
url = surl(url)
print(url)