Home > other >  The data flow of python source code to extract
The data flow of python source code to extract

Time:09-30

How to extract the data flow in the python source code, is from input to output,
For example:

 
Def deal_import (origin_code) :

Import_list=[]
Origin_code=origin_code. The lower ()
Code_lines=removeComments (origin_code)
One_split_list=code_lines. Split (" import ")
For twosplit one_split_list in:
Two_spilt_list=twosplit. Split (" from ")
Remove_list=remmove_empty (two_spilt_list)
If len (remove_list)!=0:
Rmas_list=rm_as (remove_list)
Import_list=import_list + rmas_list
Code_def=import_list [1]
Code_import=import_list
Code_import. Pop ()
Code_import=list (set (code_import))
Code_import. Sort ()
Return code_import, code_def


 origin_code - & gt; Origin_code - & gt; Code_lines - & gt; . -> Code_import. 


Extracted from the function of input to output, variable by the number of the path, the line of the extracted, at the same time, the substitution of variables in turn for VAR1, VAR2,,,, VARn

CodePudding user response:

What are you doing this is to code encryption? Feel want to write an interpreter, a little complicated,
If just do code encryption can try cython

CodePudding user response:

Essence is not encrypted, actually is to use the AST extract of the whole data stream, similar to the slice of the code, mainly for the subsequent testing malicious code and do some of the early treatment,
  • Related