本文整理匯總了Python中string.atol方法的典型用法代碼示例。如果您正苦於以下問題:Python string.atol方法的具體用法?Python string.atol怎麽用?Python string.atol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類string
的用法示例。
在下文中一共展示了string.atol方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addr
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def addr (self, mytab):
l = []
for i in mytab :
l.append(str(hex(ord(i))))
if(len(l) > 0) :
l.reverse()
var = l.pop(0)
for i in l :
if(len(i) == 3) :
if(i == "0x0") :
i = i + "0"
else :
i = i[:2] + "0" + i[2]
var = var + i[2:]
#print "VAR %s" % var
addresse = string.atol(var, 16)
else :
addresse = 0
return (addresse)
示例2: test_atol
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def test_atol(self):
self.assertEqual(string.atol(" 1 "), 1L)
self.assertRaises(ValueError, string.atol, " 1x ")
self.assertRaises(ValueError, string.atol, " x1 ")
示例3: checkFingerprints
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def checkFingerprints(self, fd) :
syscalls_hijack = []
end = 0
self.getSyscalls()
self.getOpcodes()
i = fd.readline()
liste = i.split()
while(liste != [] and end == 0):
if(liste[0] != '#') :
self.syscalls_fingerprints.map_syscalls[int(liste[0])] = [string.atol(liste[1], 16), liste[3] + " " + liste[4]]
else :
if(len(liste) > 1) :
if(liste[1] == "END"):
end = -1
i = fd.readline()
liste = i.split()
print "++ Checking Syscalls Fingerprints !!!"
for i in self.lists_syscalls:
if((self.syscalls_fingerprints.map_syscalls[i[0]][0] != self.syscalls_mem.map_syscalls[i[0]][0]) or (self.syscalls_fingerprints.map_syscalls[i[0]][1] != self.syscalls_mem.map_syscalls[i[0]][1])):
syscalls_hijack.append([i[0], i[1]])
if(syscalls_hijack != []):
print "\t** LISTS OF SYSCALLS HIJACK !!"
for i in syscalls_hijack:
print "\t\t** %d\t %-15s" %(i[0], i[1])
print "\n\t** PLEASE REINSTALL YOUR SYSTEM NOW !!!"
else:
print "\t** NO SYSCALLS HIJACK"
示例4: _iphexatodec
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def _iphexatodec(self, iphexa) :
ipdec=""
for i in range(0, 8, 2) :
ipdec = "%d" % string.atol(iphexa[i:i+2], 16) + "." + ipdec
if(iphexa[9:] == "0000") :
ipdec = ipdec[:-1] + ":" + "*"
else :
ipdec = ipdec[:-1] + ":" + "%d" % string.atol(iphexa[9:], 16)
return ipdec
示例5: _getBase
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def _getBase(self) :
base = ulibzeppoo.idtr()
return string.atol(base, 16)
示例6: strtocidr
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def strtocidr(ips):
"""returns CIDR start + length from string"""
rng = 32
pos = string.find(ips, '/')
if not pos == -1:
rng = string.atoi(ips[pos+1:])
ips = ips[:pos]
if string.find(ips, '.') == -1:
ip = string.atol(ips)
else:
ip = strtoip(ips)
if rng < 0 or rng > 32:
raise ValueError, "CIDR length out of range"
return (ip, rng)
示例7: _str_to_num
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def _str_to_num(n):
"""
Convert a hex or octal string to a decimal number.
:param n: Hex or octal string to be converted.
:return: Resulting decimal number.
"""
val = 0
col = long(1)
if n[:1] == 'x':
n = '0' + n
if n[:2] == '0x':
# hex
n = string.lower(n[2:])
while len(n) > 0:
l = n[len(n) - 1]
val = val + string.hexdigits.index(l) * col
col = col * 16
n = n[:len(n) - 1]
elif n[0] == '\\':
# octal
n = n[1:]
while len(n) > 0:
l = n[len(n) - 1]
if ord(l) < 48 or ord(l) > 57:
break
val = val + int(l) * col
col = col * 8
n = n[:len(n) - 1]
else:
val = string.atol(n)
return val
示例8: main
# 需要導入模塊: import string [as 別名]
# 或者: from string import atol [as 別名]
def main(options, arguments):
#print 'options %s' % options
#print 'arguments %s' % arguments
if(options.device != None) :
if(options.device == '/dev/mem') :
mmemory = Mem()
elif(options.device == '/dev/kmem') :
mmemory = Kmem()
else:
usage()
else :
mmemory = Kmem()
if(options.usemmap == None):
options.usemmap = 0
if(options.view != None):
if(options.view == 'tasks'):
ttasks = GVTasks(mmemory, options.usemmap)
ttasks.viewTasks()
elif(options.view == 'syscalls'):
mysyscalls = GVSyscalls(mmemory, options.usemmap)
mysyscalls.viewSyscalls()
elif(options.view == 'networks'):
nnetworks = GVNetworks(mmemory, options.usemmap)
nnetworks.viewNetworks()
elif(options.check != None):
if(options.check == 'tasks'):
ttasks = GVTasks(mmemory, options.usemmap)
ttasks.checkViewTasks()
elif(options.check == 'networks'):
nnetworks = GVNetworks(mmemory, options.usemmap)
nnetworks.checkViewNetworks()
elif(options.fingerprints != None):
ffingerprints = Fingerprints(mmemory)
if(options.fingerprints[1] == 'create'):
ffingerprints.doFingerprints(options.fingerprints[0])
elif(options.fingerprints[1] == 'check'):
ffingerprints.checkFingerprints(options.fingerprints[0])
elif(options.bump != None):
mmemory.open("r", options.usemmap)
mmemory.dump(string.atol(options.bump[0], 16), int(options.bump[1]), options.bump[2])
mmemory.close()
else:
usage()