到目前为止我使用PyQt类做了什么:
all_Addresses = QNetworkInterface.allAddresses() #list-of-QHostAddress
for addr in all_Addresses:
print(addr.toString())
Run Code Online (Sandbox Code Playgroud)
输出:
172.16.0.186 - Virtual Interface IP address
192.168.10.2 - Physical interface IP address. I want this one.
127.0.0.1
Run Code Online (Sandbox Code Playgroud)
使用socket:
import socket
print(socket.gethostbyname(socket.gethostname()))
Run Code Online (Sandbox Code Playgroud)
输出:
172.16.0.186 - When openVPN is on
192.168.10.2 - When its off
Run Code Online (Sandbox Code Playgroud)
我复制了一个从Web获得的HelloServlet应用程序并将其放在ROOT文件夹中.我运行服务器,它不起作用.怎么了?我认为它关于Java类的位置.
>>> import itertools
>>> n = [1,2,3,4]
>>> combObj = itertools.combinations(n,3)
>>>
>>> combObj
<itertools.combinations object at 0x00000000028C91D8>
>>>
>>> list(combObj)
[(1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]
>>>
>>> for i in list(combObj): #This prints nothing
... print(i)
...
Run Code Online (Sandbox Code Playgroud)
我怎样才能遍历combObj?
我怎样才能转换
[(1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]
为
[[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]