💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC=1,5] >[success] # 将序列拆分成单独变量 通过多变量赋值,将一组数据例如list 进行拆分成多个一一对应的变量数据 >[danger] ##### 例子一 - 查分元组 ~~~ p = (4,5) x,y = p print(x,y) ~~~ >[danger] ##### 例子二-拆分列表 ~~~ data = ['ACME',"50",91.1,(2012,12,21)] name,shares,price,date = data print(name,shares,price,date) ~~~ >[danger] ##### 例子三-元组列表嵌套 ~~~ data = ['ACME',"50",91.1,(2012,12,21)] name,shares,price,(year,mon,day) = data print(name,shares,price,year,mon,day) ~~~ >[danger] ##### 列子四-拆分字符串 ~~~ s="HELLO" a,b,c,d,e = s print(a,b,c,d,e) ~~~ >[danger] ##### 列子五-丢弃某些特定值 可以通过设置某些不常用变量来舍弃,特定值 `_` ~~~ data = ['ACEM',50,91.1,(2012,12,21)] _,share,price,_ = data print(share,price) ~~~