¿Existe un convertidor de software que pueda convertir automáticamente este código python en PHP?Conversión de código Python a PHP
#!/usr/bin/python
import math
def calcNumEntropyBits(s):
if len(s) <= 0: return 0.0
symCount = {}
for c in s:
if c not in symCount: symCount[c] = 1
else: symCount[c] += 1
entropy = 0.0
for c,n in symCount.iteritems():
prob = n/float(len(s))
entropy += prob * (math.log(prob)/math.log(2))
if entropy >= 0.0: return 0.0
else: return -(entropy*len(s))
def testEntropy(s):
print "Bits of entropy in '%s' is %.2f" % (s, calcNumEntropyBits(s))
testEntropy('hello world')
testEntropy('bubba dubba')
testEntropy('aaaaaaaaaaa')
testEntropy('aaaaabaaaaa')
testEntropy('abcdefghijk')
Desactiva el "convertidor de software". –
Ha. ¡Stack Overflow necesita un método API donde puedas enviar código PHP y recuperar Python! – JAL
@JAL [Universal-transpiler] (https://github.com/jarble/universal-transpiler) puede convertir un pequeño subconjunto del lenguaje de programación de PHP en Python. Sin embargo, todavía es un trabajo en progreso. –