python helloworld

#!/usr/bin/env python2.7


import os
import sys
import binwalk
#import hexdump
import os
import sys,string,   shutil,    re
import base64
import struct
#import pefile
import ctypes
import zlib

# import put_family_c2


def add_fun0():
    sum = 0
    for x in range(101):
      sum = sum + x
    print(sum)


def func(a, b):
    c = a+b
    #print('the c is ', c)
    return c;

def hexdump(src, length=16):
    FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)])
    lines = []
    for c in xrange(0, len(src), length):
       chars = src[c:c + length]
       hex = ' '.join(["%02x" % ord(x) for x in chars])
       printable = ''.join(["%s" % ((ord(x) <= 127 and FILTER[ord(x)]) or '.') for x in chars])
       lines.append("%04x  %-*s  %s\n" % (c, length * 3, hex, printable))
    return ''.join(lines)

def descrypt(data):
 try:
 # data = base64.encodestring(data)
 # print(hexdump(data))
  num = 0 
  data = zlib.decompress(data)
  # return result
  return (True, result)
 except Exception as e:
    print(e)
    return (False, "")

#https://blog.csdn.net/manok/article/details/102539782

def main():
    pass
    print('Hello World!')
    #sys.stdout.write("__name__ = '%s'\n" % __name__)
    func(1,2);
    sys.stdout.write("__name__ = '%s'\n" % func(1,2))
    print(hexdump("1234567890abcdefghjk"))
    print(hexdump('\x55'*48));
    FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)])
    sys.stdout.write("FILTER = '%s'\n" % FILTER)
    sys.stdout.write("FILTER = '%s'\n" % range(256));
    FILTER = ''.join("123");
    sys.stdout.write("FILTER = '%s'\n" % len(repr(chr(1))));
    sys.stdout.write("FILTER = '%s'\n" % len(repr(chr(0))));
    sys.stdout.write("FILTER = '%s'\n" % len(repr(chr(255))));
    sys.stdout.write("FILTER = '%s'\n" % chr(7));
    sys.stdout.write("FILTER = '%s'\n" % chr(0x31));
    sys.stdout.write("FILTER = '%s'\n" % chr(48));
    sys.stdout.write("FILTER = '%s'\n" % len(repr(chr(49))));
    pass;
 
if __name__ == '__main__':
    main();
 

你可能感兴趣的:(python,servlet,开发语言)