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解析.pyd文件的詳細代碼,希望對大傢有所幫助。在此也非常感謝大傢對WalkonNet網站的支持!

推薦閱讀: