Pythonic

这是一个会长期更新的文章,记录那些我遇到的 Python 中的 奇技淫巧

遍历列表中的元素,并储存为变量

笨办法:

a = ['Admin', '127.0.0.1', '8080', 'maya_matthew_guaranty']
name = a[0]
server = a[1]
port = a[2]
password = a[3]

Pythonic:

a = ['Admin', '127.0.0.1', '8080', 'maya_matthew_guaranty']
name , server, port , password = a
Comments
Write a Comment