python解析.pyd文件

有的时候,为了对python文件进行加密,会把python模块编译成.pyd文件,供其他人调用。拿到一个.pyd文件,在没有文档说明的情况下,可以试试查看模块内的一些函数和类的用法。
首先 import XXX(pyd的文件名)
然后直接
print(dir(XXX))
print(help(xxx))

其中dir( ) 列出了属性和方法
而hlep()直接列出了其中的函数以及参数,并且是源码的函数名和类型,非常直观。
例如我这里的一个例子,输出如下:

['RC', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'call_func', 'collision_recover', 'disable_robot', 'drag_mode_enable', 'enable_robot', 'get_analog_input', 'get_analog_output', 'get_collision_level', 'get_current_line', 'get_digital_input', 'get_digital_output', 'get_joint_position', 'get_loaded_program', 'get_payload', 'get_program_state', 'get_rapidrate', 'get_robot_state', 'get_sdk_version', 'get_tcp_position', 'get_tool_id', 'get_user_frame_id', 'is_extio_running', 'is_in_collision', 'is_in_drag_mode', 'is_in_pos', 'is_on_limit', 'jog', 'jog_stop', 'joint_move', 'kine_forward', 'kine_inverse', 'linear_move', 'login', 'logout', 'power_off', 'power_on', 'program_abort', 'program_load', 'program_pause', 'program_resume', 'program_run', 'quaternion_to_rot_matrix', 'rot_matrix_to_quaternion', 'rot_matrix_to_rpy', 'rpy_to_rot_matrix', 'servo_j', 'servo_move_enable', 'servo_p', 'set_analog_output', 'set_collision_level', 'set_digital_output', 'set_error_handler', 'set_payload', 'set_rapidrate', 'set_tool_data', 'set_tool_id', 'set_user_frame_data', 'set_user_frame_id', 'shut_down', 'torque_control_enable', 'torque_feedforward']
Help on module jkrc:

NAME
    jkrc - Example module that creates an extension type.

CLASSES
    builtins.object
        RC
    
    class RC(builtins.object)
     |  RC objects
     |  
     |  Methods defined here:
     |  
     |  __init__(self, /, *args, **kwargs)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  call_func(...)
     |      description
     |  
     |  collision_recover(...)
     |      description
     |  
     |  disable_robot(...)
     |      description
     |  
     |  drag_mode_enable(...)
     |      description
     |  
     |  enable_robot(...)
     |      description
     |  
     |  get_analog_input(...)
     |      description
     |  
     |  get_analog_output(...)
     |      description
     |  
     |  get_collision_level(...)
     |      description
     |  
     |  get_current_line(...)
     |      description
     |  
     |  get_digital_input(...)
     |      description
     |  
     |  get_digital_output(...)
     |      description
     |  
     |  get_joint_position(...)
     |      description
     |  
     |  get_loaded_program(...)
     |      description
     |  
     |  get_payload(...)
     |      description
     |  
     |  get_program_state(...)
     |      description
     |  
     |  get_rapidrate(...)
     |      description
     |  
     |  get_robot_state(...)
     |      description
     |  
     |  get_sdk_version(...)
     |      description
     |  
     |  get_tcp_position(...)
     |      description
     |  
     |  get_tool_id(...)
     |      description
     |  
     |  get_user_frame_id(...)
     |      description
     |  
     |  is_extio_running(...)
     |      description
     |  
     |  is_in_collision(...)
     |      description
     |  
     |  is_in_drag_mode(...)
     |      description
     |  
     |  is_in_pos(...)
     |      description
     |  
     |  is_on_limit(...)
     |      description
     |  
     |  jog(...)
     |      description
     |  
     |  jog_stop(...)
     |      description
     |  
     |  joint_move(...)
     |      description
     |  
     |  kine_forward(...)
     |      description
     |  
     |  kine_inverse(...)
     |      description
     |  
     |  linear_move(...)
     |      description
     |  
     |  login(...)
     |      Log in the specified robot
     |  
     |  logout(...)
     |      Log out the specified robot
     |  
     |  power_off(...)
     |      description
     |  
     |  power_on(...)
     |      description
     |  
     |  program_abort(...)
     |      description
     |  
     |  program_load(...)
     |      description
     |  
     |  program_pause(...)
     |      description
     |  
     |  program_resume(...)
     |      description
     |  
     |  program_run(...)
     |      description
     |  
     |  quaternion_to_rot_matrix(...)
     |      description
     |  
     |  rot_matrix_to_quaternion(...)
     |      description
     |  
     |  rot_matrix_to_rpy(...)
     |      description
     |  
     |  rpy_to_rot_matrix(...)
     |      description
     |  
     |  servo_j(...)
     |      description
     |  
     |  servo_move_enable(...)
     |      description
     |  
     |  servo_p(...)
     |      description
     |  
     |  set_analog_output(...)
     |      description
     |  
     |  set_collision_level(...)
     |      description
     |  
     |  set_digital_output(...)
     |      description
     |  
     |  set_error_handler(...)
     |      description
     |  
     |  set_payload(...)
     |      description
     |  
     |  set_rapidrate(...)
     |      description
     |  
     |  set_tool_data(...)
     |      description
     |  
     |  set_tool_id(...)
     |      description
     |  
     |  set_user_frame_data(...)
     |      description
     .......

你可能感兴趣的:(python,python)