本文整理汇总了Python中socket.f函数的典型用法代码示例。如果您正苦于以下问题:Python f函数的具体用法?Python f怎么用?Python f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了f函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testIPv4toString
def testIPv4toString(self):
if not hasattr(socket, 'inet_pton'):
return # No inet_pton() on this platform
from socket import inet_aton as f, inet_pton, AF_INET
g = lambda a: inet_pton(AF_INET, a)
self.assertEquals('\x00\x00\x00\x00', f('0.0.0.0'))
self.assertEquals('\xff\x00\xff\x00', f('255.0.255.0'))
self.assertEquals('\xaa\xaa\xaa\xaa', f('170.170.170.170'))
self.assertEquals('\x01\x02\x03\x04', f('1.2.3.4'))
self.assertEquals('\x00\x00\x00\x00', g('0.0.0.0'))
self.assertEquals('\xff\x00\xff\x00', g('255.0.255.0'))
self.assertEquals('\xaa\xaa\xaa\xaa', g('170.170.170.170'))
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:14,代码来源:test_socket.py
示例2: testStringToIPv4
def testStringToIPv4(self):
if not hasattr(socket, 'inet_ntop'):
return # No inet_ntop() on this platform
from socket import inet_ntoa as f, inet_ntop, AF_INET
g = lambda a: inet_ntop(AF_INET, a)
self.assertEquals('1.0.1.0', f('\x01\x00\x01\x00'))
self.assertEquals('170.85.170.85', f('\xaa\x55\xaa\x55'))
self.assertEquals('255.255.255.255', f('\xff\xff\xff\xff'))
self.assertEquals('1.2.3.4', f('\x01\x02\x03\x04'))
self.assertEquals('1.0.1.0', g('\x01\x00\x01\x00'))
self.assertEquals('170.85.170.85', g('\xaa\x55\xaa\x55'))
self.assertEquals('255.255.255.255', g('\xff\xff\xff\xff'))
开发者ID:249550148,项目名称:gevent,代码行数:14,代码来源:test_socket.py
示例3: testStringToIPv4
def testStringToIPv4(self):
if not hasattr(socket, "inet_ntop"):
return # No inet_ntop() on this platform
from socket import inet_ntoa as f, inet_ntop, AF_INET
g = lambda a: inet_ntop(AF_INET, a)
self.assertEquals("1.0.1.0", f("\x01\x00\x01\x00"))
self.assertEquals("170.85.170.85", f("\xaa\x55\xaa\x55"))
self.assertEquals("255.255.255.255", f("\xff\xff\xff\xff"))
self.assertEquals("1.2.3.4", f("\x01\x02\x03\x04"))
self.assertEquals("1.0.1.0", g("\x01\x00\x01\x00"))
self.assertEquals("170.85.170.85", g("\xaa\x55\xaa\x55"))
self.assertEquals("255.255.255.255", g("\xff\xff\xff\xff"))
开发者ID:slide,项目名称:main,代码行数:15,代码来源:test_socket.py
示例4: testStringToIPv6
def testStringToIPv6(self):
if not hasattr(socket, 'inet_ntop'):
return # No inet_ntop() on this platform
try:
from socket import inet_ntop, AF_INET6, has_ipv6
if not has_ipv6:
return
except ImportError:
return
f = lambda a: inet_ntop(AF_INET6, a)
self.assertEquals('::', f('\x00' * 16))
self.assertEquals('::1', f('\x00' * 15 + '\x01'))
self.assertEquals(
'aef:b01:506:1001:ffff:9997:55:170',
f('\x0a\xef\x0b\x01\x05\x06\x10\x01\xff\xff\x99\x97\x00\x55\x01\x70')
)
开发者ID:249550148,项目名称:gevent,代码行数:17,代码来源:test_socket.py
示例5: testIPv4toString
def testIPv4toString(self):
if not hasattr(socket, "inet_pton"):
return # No inet_pton() on this platform
from socket import inet_aton as f, inet_pton, AF_INET
g = lambda a: inet_pton(AF_INET, a)
self.assertEquals("\x00\x00\x00\x00", f("0.0.0.0"))
self.assertEquals("\xff\x00\xff\x00", f("255.0.255.0"))
self.assertEquals("\xaa\xaa\xaa\xaa", f("170.170.170.170"))
self.assertEquals("\x01\x02\x03\x04", f("1.2.3.4"))
self.assertEquals("\xff\xff\xff\xff", f("255.255.255.255"))
self.assertEquals("\x00\x00\x00\x00", g("0.0.0.0"))
self.assertEquals("\xff\x00\xff\x00", g("255.0.255.0"))
self.assertEquals("\xaa\xaa\xaa\xaa", g("170.170.170.170"))
self.assertEquals("\xff\xff\xff\xff", g("255.255.255.255"))
开发者ID:slide,项目名称:main,代码行数:17,代码来源:test_socket.py
示例6: testIPv6toString
def testIPv6toString(self):
if not hasattr(socket, 'inet_pton'):
return # No inet_pton() on this platform
try:
from socket import inet_pton, AF_INET6, has_ipv6
if not has_ipv6:
return
except ImportError:
return
f = lambda a: inet_pton(AF_INET6, a)
self.assertEquals('\x00' * 16, f('::'))
self.assertEquals('\x00' * 16, f('0::0'))
self.assertEquals('\x00\x01' + '\x00' * 14, f('1::'))
self.assertEquals(
'\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae',
f('45ef:76cb:1a:56ef:afeb:bac:1924:aeae')
)
开发者ID:249550148,项目名称:gevent,代码行数:18,代码来源:test_socket.py
示例7: testIPv6toString
def testIPv6toString(self):
if not hasattr(socket, "inet_pton"):
return # No inet_pton() on this platform
try:
from socket import inet_pton, AF_INET6, has_ipv6
if not has_ipv6:
return
except ImportError:
return
f = lambda a: inet_pton(AF_INET6, a)
self.assertEquals("\x00" * 16, f("::"))
self.assertEquals("\x00" * 16, f("0::0"))
self.assertEquals("\x00\x01" + "\x00" * 14, f("1::"))
self.assertEquals(
"\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae",
f("45ef:76cb:1a:56ef:afeb:bac:1924:aeae"),
)
开发者ID:slide,项目名称:main,代码行数:19,代码来源:test_socket.py
注:本文中的socket.f函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论