def wx(): a = ‘wx‘ b = ‘无邪‘ return a, b print(wx()) print(type(wx())) -----------执行结果--------------------- (‘wx‘, ‘无邪‘) <class ‘tuple‘>
def wx(): a = ‘wx‘ b = ‘无邪‘ return (a, b) print(wx()) print(type(wx())) -----------执行结果------------------- (‘wx‘, ‘无邪‘) <class ‘tuple‘>
def wx(): a = ‘wx‘ b = ‘无邪‘ return [a, b] print(wx()) print(type(wx())) -------------执行结果---------------- [‘wx‘, ‘无邪‘] <class ‘list‘>
return返回一个数,是原类型,返回多个是元祖类型
def wx():
a = ‘wx‘
b = ‘无邪‘
return [a, b],[a,b]
print(wx())
print(type(wx()))
-------------执行结果----------------
([‘wx‘, ‘无邪‘], [‘wx‘, ‘无邪‘])
<class ‘tuple‘>
def wx(): a = ‘wx‘ b = ‘无邪‘ return {a, b} print(wx()) print(type(wx())) -----------执行结果--------------- {‘无邪‘, ‘wx‘} <class ‘set‘>
return返回一个数,是原类型,返回多个是元祖类型
def wx():
a = ‘wx‘
b = ‘无邪‘
return {a, b},{a,b}
print(wx())
print(type(wx()))
-----------执行结果---------------
({‘wx‘, ‘无邪‘}, {‘wx‘, ‘无邪‘})
<class ‘tuple‘>
def wx(): a = ‘wx‘ b = ‘无邪‘ yield [a, b] print(wx()) print(type(wx())) print(next(wx())) print(next(wx())[0]) print(next(wx())[1]) -------------执行结果----------------------- <generator object wx at 0x0000021AC9B93BA0> <class ‘generator‘> [‘wx‘, ‘无邪‘] wx 无邪
原文:https://www.cnblogs.com/tzxy/p/11045880.html