[英]Ignoring part of a tuple returned in Python?
With the following code, is there any way to specify that I don't care about the 'address' part of the tuple returned?使用以下代码,有什么方法可以指定我不关心返回的元组的“地址”部分?
(data, address) = socket.recvfrom(512)
Ideally, I'd like to do something like this:理想情况下,我想做这样的事情:
data = socket.recvfrom(512)
Thanks!谢谢!
data = socket.recvfrom(512)[0]
option one, just grab the elements you are intereseted in:选项一,只需抓住您感兴趣的元素:
data = socket.recvfrom(512)[0]
option two, use a word that tells the reader you don't care:选项二,用一个词告诉读者你不在乎:
data, dummy = socket.recvfrom(512)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.