• L
    Added python3 version of converter, errors with converting to binary has been cured in this script. · e66dab0b
    leroyron 提交于
    1st Errors-----------------:
    The problem is that in Python 2 the print function is different in Python 3.
    Python 2:
    print ''
    
    Python 3: print is a function and no keyword so it needs brackets:
    print('')
    
    2nd Errors-----------------:
    struct.error: argument for 's' must be a bytes object
    a.
    signature = struct.pack('<12s', 'Three.js 003') Changed To signature = struct.pack(b'<12s', b'Three.js 003')
    
    b.
    out.write("".join(buffer)) Changed To > out.write(b"".join(buffer))
    
    Explanation:
    
    The error
    packed = struct.pack(1, 'ab', 2.7)
    
    With Python 3, 'ab' isn't a bytes object, what was called a str on Python 2, it's unicode. You need to use:
    packed = struct.pack(1, b'ab', 2.7)
    
    which tells Python that 'ab' is a byte literal. See PEP 3112 for more info.
    e66dab0b
convert_obj_three_for_python3.py 47.7 KB