Warning: ftp_fget() expects parameter 1 to be resource, null given in /www/wwwroot/new.weijing.co/wp-admin/includes/class-wp-filesystem-ftpext.php on line 146

 Python 列表与元组之间相互转换

Python 定义了 list()和 tuple() 函数,它们会分别把传递给它们的值,转换为列表和元组版本。

colors = [\'红\', \'绿\', \'黄\']
print(tuple(colors))
nums=(1,2,3)
print(list(nums))

运行结果:

(\’红\’, \’绿\’, \’黄\’)
[1, 2, 3]

发表评论

您的电子邮箱地址不会被公开。

Shopping Cart