Python-based interface interaction method and device, equipment, storage medium and product
By responding to interactive operations in Python teaching scenarios, determining and calling functions of interactive functional components, the poor learning experience caused by pure code display teaching methods is solved, and more efficient teaching interactivity and expressiveness are achieved.
Patent Information
- Application Number
- CN202510149505.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2025-06-03
AI Technical Summary
In a pure script teaching scenario based on Python, students can only learn the functions of component modules or function calls through code display, resulting in poor learning experience, insufficient interactivity and expressiveness, which affects the in-depth level of teaching understanding.
By responding to the interaction operation of interface components in the target interactive interface, the interactive functional components are determined, and their corresponding component functions are called, the function execution results are generated, and the execution results are displayed in the code compilation area, interface visualization and interactive actions between the code and the visual components are realized.
It improves the learning experience of Python programming teaching, enhances students' understanding during the teaching process, improves the interactivity and expressiveness of the teaching process, and allows students to more intuitively understand component display and their function calls and execution processes.
Smart Images

Figure CN120085849A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular, to a Python-based interface interaction method, device, equipment, storage medium, and product. Background Art
[0002] In the teaching scenario based on pure Python scripts, there is no externalized effect during the teaching demonstration process. Students can only learn the function implementation of corresponding component modules or function calls through code display. For the teaching and research scenario, the teaching method of pure code display has a poor learning experience for students, and the interactivity and expressiveness are insufficient, and to a certain extent, the depth of teaching understanding is weak. Summary of the Invention
[0003] The present invention provides a Python-based interface interaction method, device, equipment, storage medium, and product to improve the learning experience of Python programming teaching, enhance the understanding of students' learning during the teaching process to a certain extent, and enhance the interactivity and expressiveness during the teaching process.
[0004] According to one aspect of the present invention, there is provided a Python-based interface interaction method, the method comprising:
[0005] In response to an interaction operation on an interface component in a target interaction interface, determining an interaction function component; the target interaction interface is obtained by rendering an interface based on a script language string; the script language string is obtained by format conversion of a target string; the target string is obtained by performing a template string extraction operation on the obtained Python-based code to be processed;
[0006] Determining and calling a component function corresponding to the interaction function component, generating a function execution result, and displaying the execution result in a code compilation area to which the code to be processed belongs.
[0007] According to another aspect of the present invention, there is provided a Python-based interface interaction device, the device comprising:
[0008] An interaction component determination module, configured to determine an interaction function component in response to an interaction operation on an interface component in a target interaction interface; the target interaction interface is obtained by rendering an interface based on a script language string; the script language string is obtained by format conversion of a target string; the target string is obtained by performing a template string extraction operation on the obtained Python-based code to be processed;
[0009] A function execution module, configured to determine and call a component function corresponding to the interaction function component, generate a function execution result, and display the execution result in a code compilation area to which the code to be processed belongs.
[0010] According to another aspect of the present invention, there is provided an electronic device, which includes:
[0011] At least one processor; and
[0012] A memory communicatively connected to the at least one processor; wherein,
[0013] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Python-based interface interaction method according to any embodiment of the present invention.
[0014] According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the Python-based interface interaction method according to any embodiment of the present invention when executed.
[0015] According to another aspect of the present invention, there is provided a computer program product including a computer program, and when the computer program is executed by a processor, the above-mentioned Python-based interface interaction method is implemented.
[0016] The technical solution of the embodiment of the present invention determines an interaction function component in response to an interaction operation on an interface component in a target interaction interface, determines and calls a component function corresponding to the interaction function component, generates a function execution result, and displays the execution result in a code compilation area to which the code to be processed belongs, realizing interface visualization in the process of Python language coding tutorials, and realizing the interaction actions between the code and the visualization components, so that the component display and its function call and execution process implemented based on the Python language can be more intuitively understood, improving the learning experience of Python programming teaching. At the same time, to a certain extent, it enhances the understanding degree of students' learning in the teaching process, as well as the interactivity and expressiveness in the teaching process.
[0017] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0019] Figure 1 It is a flowchart of a Python-based interface interaction method provided in Embodiment 1 of the present invention;
[0020] Figure 2 It is a flowchart of a Python-based interface interaction method provided in Embodiment 2 of the present invention;
[0021] Figure 3 It is a schematic structural diagram of a Python-based interface interaction device provided in Embodiment 3 of the present invention;
[0022] Figure 4 It is a schematic structural diagram of an electronic device for implementing the Python-based interface interaction method of the embodiments of the present invention. Specific Embodiments
[0023] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above accompanying drawings are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0025] Embodiment 1
[0026] Figure 1The flowchart of an interface interaction method provided in Embodiment 1 of the present invention. This embodiment is applicable to the visualization of programming interfaces and interface interaction in the teaching process based on the Python programming language. This method can be executed by an interface interaction device based on Python. The interface interaction device based on Python can be implemented in the form of hardware and / or software, and the interface interaction device based on Python can be configured in an electronic device. As Figure 1 shown, the method includes:
[0027] S110. In response to an interaction operation on an interface component in a target interaction interface, determine an interaction function component; the target interaction interface is obtained by rendering an interface based on a script language string; the script language string is obtained by format conversion of a target string; the target string is obtained by performing a template string extraction operation on the to-be-processed code implemented based on Python obtained.
[0028] S120. Determine and call a component function corresponding to the interaction function component, generate a function execution result, and display the execution result in the code compilation area where the to-be-processed code belongs.
[0029] Among them, the target interaction interface can be the UI (User Interface) corresponding to the to-be-processed code, which is used to visualize the function components in the to-be-processed code and can perform interaction actions.
[0030] Among them, the to-be-processed code can include teaching code and a template string for generating the target interaction interface, that is, a formatted string, which can be represented by "f'…'" or "f"…"", and valid Python variables or expressions can be embedded in the string, and the format is usually set to "{}", and Python can automatically replace it with the corresponding value.
[0031] Specifically, add a template string to the code to be processed, and define the UI page generation code in the template string. The UI page generation code can include interactive function components for learning and display, such as Button components, Input components, and List dropdown components. The component styles of the interactive function components can be predefined. Different interactive function components can display the same or different styles in the UI. The component styles can be pre-compiled and stored by combining HTML (HyperText Markup Language) and CSS (Cascading Style Sheets), and the corresponding component styles can be directly called for component rendering later. Function definitions of the interactive function components can also be defined in the code to be processed, that is, the functions that the interactive function components are used to implement. Specifically, during the interaction with the corresponding interactive function components, the function call results of the components can be synchronously displayed in the code compilation area to assist students in understanding the interactive function components and their function definitions.
[0032] The target interactive interface can be generated by compiling the code to be processed written by relevant technical personnel, such as teaching staff. The specific generation method is as follows:
[0033] Step a1: Obtain the code to be processed implemented based on the Python programming language by relevant technical personnel.
[0034] Step a2: Extract the template string in the code to be processed to obtain the target string.
[0035] Step a3: Convert the format of the target string to obtain a script language string.
[0036] Step a4: Render the interface of the code to be processed according to the script language string to generate the target interactive interface.
[0037] In the above steps, locate the template string in the code to be processed. Specifically, it can be located according to the string identifier of the template string, such as "f'…'" or "f\"…\"". Identify the string flag, identify the start position and end position, and then extract the string between the identified start position and end position, and use the extracted content as the template string. Extract the target string according to the variables or expressions in the template string. For example, identify based on the format symbol "{}" of the variable or expression, and use the content between the start format symbol "{" and the end format symbol "}" as the target string. The number of target strings can be one or more.
[0038] To achieve the invocation of a target string based on the Python language in a JS (JavaScript) environment, it is necessary to convert the target string based on the Python language into a script language string (i.e., a JS string) that can be executed in the JS environment.
[0039] Specifically, perform format conversion on the target string to obtain a script language string. Among them, the script language string is specifically a JS string, which can be, for example, by using template literals to directly embed variables or expressions into the string. Template literals use backticks (`) to enclose the string, and variables or expressions can be embedded through ${}. Based on the script language string, use the rendering function in the UI rendering library of Python to perform UI interface rendering in the JS environment according to the component styles predefined in the template string of the code to be processed, and generate a target interaction interface.
[0040] Among them, the target interaction interface includes at least one interface component. The style code of the interface component is written in the template string of the code to be processed, and the call function of the interface component is defined in the code to be processed. In a teaching scenario, the target interaction interface can be shown to students. When students or teachers perform interaction operations on the interface components through the target interaction interface, determine the interaction function components that perform the interaction operations.
[0041] Traverse the code to be processed and determine the component function corresponding to the interaction function component, execute the component function to generate a function execution result, and display the execution result in the code compilation area to which the code to be processed belongs, so that students in the teaching scenario can intuitively see the interaction result of the interaction function component, as well as the traversal and call execution process of the component function of the interaction function component.
[0042] The technical solution of the embodiment of the present invention realizes the interface visualization in the process of Python language coding tutorials and the interaction action between the code and the visualization components by responding to the interaction operation on the interface components in the target interaction interface, determining the interaction function components, calling the component functions corresponding to the interaction function components, generating function execution results, and displaying the execution results in the code compilation area to which the code to be processed belongs. Thus, it is possible to more intuitively understand the component display, function call, and execution process implemented based on the Python language, improving the learning experience of Python programming teaching. At the same time, to a certain extent, it enhances the understanding degree of students' learning in the teaching process, as well as the interactivity and expressiveness in the teaching process.
[0043] It should be noted that for the started target interaction interface, an interface closing operation can be performed. There are two types of component types in the interface components of the target interaction interface. One is the closing function component, which is used to perform the interface closing action, and there is only one in number, which can be pre-compiled and generated in the code to be processed. The other is the non-closing function component, and the number can be one or more, such as Button components or Input components, etc. Different non-closing function components are used to implement different logical functions.
[0044] In an alternative embodiment, determining and invoking the component function corresponding to the interaction function component to generate a function execution result includes: if the interaction function component is a non-closing function component, performing a regular expression match on the function names in the script language string according to the function name corresponding to the component attribute of the interaction function component to determine the target function; generating a function execution result according to the target function.
[0045] Among them, the component attributes corresponding to different types of interaction function components are different. For example, the component attribute corresponding to the Button component can be the Onclick (user click event) attribute; the component attribute corresponding to the Input component can be the Onchange attribute (this event is triggered when a value is input in the input box), and the component attribute corresponding to the List component can be the Options (list dropdown selection) attribute.
[0046] Specifically, perform a regular expression match on each function name in the script language string according to the function name of the component attribute of the interaction function component to determine the function return value of the function corresponding to the component attribute of the interaction function component, and use this function return value as the target function. For example, when traversing to this statement <button onClick={handleClick}>< / button> , the component attribute corresponding to Button is the onclick attribute, and its function name is "onclick". Perform a regular expression match on the function names in the script language string, and the function corresponding to the component attribute of the interaction function component obtained by the match is the onclick function, and the corresponding function return value is "handleClick", then the target function is the "handleClick()" function. Call the pre-defined handleClick() function in the code to be processed to execute and generate a function execution result.
[0047] When the above technical solution determines that the interaction function component is a non-closing function component, it determines the target function corresponding to the interaction function component based on regular expression matching, and executes its corresponding pre-defined function according to the function return value to generate a function execution result, realizing the code compilation and execution process when performing interaction operations on interface components in a visual manner, and improving the interaction experience in the teaching process.
[0048] During the execution result process of the above generation function, the Python compiler can be called for execution. Specifically, the Python editor is Skulpt, which is a Python interpreter implemented in JavaScript. It can run Python code in a browser environment.
[0049] It should be noted that due to the different component attributes of different interactive function components, the component attributes of some interactive function components do not carry function parameter values, such as Button; while the component attributes of some interactive function components require writing function parameter values, such as the Input component. The content entered by the user in the Input input box is the passed function parameter value.
[0050] Optionally, if the target function does not carry function parameter values, the target function is called through the function call method corresponding to the Python interpreter to execute the target function and obtain the function execution result.
[0051] Among them, the function call method corresponding to the Python interpreter (Skulpt) is specifically Sk.misceval.callsimAsync. The Sk.misceval.callsimAsync method of Skulpt asynchronously calls a Python function or method and returns a Promise object. A Promise is a specific asynchronous programming mechanism in JavaScript, used to represent the final completion (or failure) of an asynchronous operation and its result value.
[0052] Specifically, if the target function does not carry function parameter values, the target function is called through the function call method Sk.misceval.callsimAsync corresponding to Skulpt, and the target function is executed to obtain the function execution result.
[0053] Optionally, if the target function carries function parameter values, the function parameter values are used as the method arguments of the function call method corresponding to the Python interpreter to call the target function, so as to execute the target function and obtain the function execution result.
[0054] Specifically, if the target function carries function parameter values, the function parameter values in the target function are obtained, and the function parameter values are used as the arguments of the function call method Sk.misceval.callsimAsync of Skulpt, and the target function is called to execute the target function to obtain the function execution result.
[0055] The above technical solution realizes the asynchronous call of Python functions with and without function parameter values by using the asynchronous call of Python functions or methods by the Python interpreter, and solves the problem of asynchronous call of Python functions in the JS environment.
[0056] It can be understood that during the execution of the target function call, the function call may fail. To further improve the convenience and flexibility of the teaching process, the code position of the target function with a failed call can be automatically located.
[0057] In an optional embodiment, a function execution result is generated according to the target function, including: if the target function is successfully executed, the function execution result is obtained and displayed in the code compilation area; and, if the target function execution fails, according to the function name of the target function, the code position of the target function in the code to be processed is located; the current display area position of the code compilation area is updated to the code position.
[0058] Specifically, if the target function is successfully executed, the function execution result can be directly displayed in the code compilation area; if the target function execution fails, the code to be processed is traversed according to the function name of the target function to determine the code position of the area where the target function is located, which can specifically be the line number of the code where the target function is located. The current display area position of the code compilation area is updated to the code position for students and teachers to more intuitively directly view the target function with a failed execution and jointly find the reason for the failure of the target function execution.
[0059] The above technical solution facilitates teachers and students to intuitively see the target function with a failed call by determining and locating the code position of the target function with a failed execution in the code to be processed, improving the convenience and flexibility of the teaching process.
[0060] It can be understood that during the teaching process, for the opened target interaction interface, the interface closing operation can be performed on the target interaction interface through the closing function component in the interface. It should be noted that since the closing function component can be one of the teaching components in the teaching process, if the closing action fails, the error reason for the execution can be displayed in the code compilation area for learning.
[0061] In an alternative embodiment, determining and invoking the component function corresponding to the interactive function component to generate a function execution result includes: if the interactive function component is a closing function component, invoking the closing component function corresponding to the closing function component through the function invocation method corresponding to the Python interpreter; executing the closing component function, if the component closing function is successfully executed, closing the target interactive interface and ending the program execution; and, if the component closing function fails to execute, generating an execution error message, closing the target interactive interface, ending the program execution, and displaying the execution error message in the code compilation area.
[0062] The closing component function corresponding to the closing function component is specifically the onClosedByUser function, which can specifically be used to respond to events of the user closing the target interactive interface or operations. It should be noted that the closing component function is a global method function, and the invocation of this function is automatically triggered when the user clicks the close button of the pop-up window.
[0063] Specifically, if the interactive function component is a closing function component, the onClosedByUser function corresponding to the closing function component is invoked and executed through the function invocation method Sk.misceval.callsimAsync of the Python interpreter Skulpt. If the component closing function is successfully executed, the target interactive interface is closed and the program execution ends. Among them, the program operation can specifically be the program code corresponding to the target interactive interface. If the component closing function fails to execute, an execution error message is generated, the target interactive interface is closed, the program execution ends, and the execution error message is displayed in the code compilation area. Among them, the execution error message is automatically generated during the execution process when the program code is invoked and fails to execute.
[0064] The above technical solution, when determining that the interactive function component is a closing function component, invokes the onClosedByUser function corresponding to the closing function component to perform a closing action on the target interactive interface, more completely reflecting the interactive execution process between the interface and the program code. By clicking the close button in the closing interface, while the interface is closed, the code execution situation in the code display area can be observed synchronously, which is convenient for students to deeply understand programming during the teaching process.
[0065] Embodiment Two
[0066] Figure 2 The flowchart of an interface interaction method based on Python provided in Embodiment Two of the present invention. This embodiment provides a preferred example based on the above embodiment.
[0067] As Figure 2 shown, the method includes the following specific steps:
[0068] S21. Obtain the code to be processed implemented by relevant technical personnel based on the Python programming language.
[0069] S22. Extract the template strings in the code to be processed to obtain the target strings.
[0070] S23. Perform format conversion on the target strings to obtain the script language strings.
[0071] S24. Render the interface of the code to be processed according to the script language strings to generate the target interactive interface.
[0072] S25. In response to the interaction operation on the interface components in the target interactive interface, determine the interactive function components; if the interactive function components are non-close function components, then execute S26 - S29; if the interactive function components are close function components, then execute S210 - S211.
[0073] S26. Perform regular matching on the function names in the script language strings according to the function names corresponding to the component attributes of the interactive function components to determine the target functions.
[0074] S27a. If the target function does not carry function parameter values, call the target function through the function call method corresponding to the Python interpreter to execute the target function and obtain the function execution result.
[0075] S27b. If the target function carries function parameter values, call the target function with the function parameter values as the method actual parameters of the function call method corresponding to the Python interpreter to execute the target function and obtain the function execution result.
[0076] S28a. If the execution of the target function is successful, obtain the function execution result and display the function execution result in the code compilation area.
[0077] S28b. If the execution of the target function fails, locate the code position of the target function in the code to be processed according to the function name of the target function.
[0078] S29. Update the current display area position of the code compilation area to the code position.
[0079] S210. Call the close component function corresponding to the close function component through the function call method corresponding to the Python interpreter to execute the close component function.
[0080] S211a. If the execution of the component close function is successful, close the target interactive interface and end the program execution.
[0081] S211b. If the component closing function fails to execute, generate an execution error message, close the target interaction interface, end the program execution, and display the execution error message in the code compilation area.
[0082] Embodiment III
[0083] Figure 3 FIG. is a schematic structural diagram of an interface interaction device based on Python provided by Embodiment III of the present invention. An interface interaction device based on Python provided by an embodiment of the present invention can be applied to the visualization of a programming interface and interface interaction in the teaching process based on the Python programming language. The interface interaction device based on Python can be implemented in the form of hardware and / or software, such as Figure 3 shown, the device specifically includes: an interaction component determination module 301 and a function execution module 302. Among them,
[0084] The interaction component determination module 301 is configured to determine an interaction function component in response to an interaction operation on an interface component in a target interaction interface; the target interaction interface is obtained by rendering an interface based on a script language string; the script language string is obtained by performing a format conversion on a target string; the target string is obtained by performing a template string extraction operation on the obtained Python-implemented code to be processed;
[0085] The function execution module 302 is configured to determine and call a component function corresponding to the interaction function component, generate a function execution result, and display the execution result in the code compilation area to which the code to be processed belongs.
[0086] Optionally, the function execution module 302 includes:
[0087] A regular expression matching unit, configured to, if the interaction function component is a non-closing function component, perform a regular expression match on the function name in the script language string according to the function name corresponding to the component attribute of the interaction function component to determine a target function;
[0088] A function execution unit, configured to generate a function execution result according to the target function.
[0089] Optionally, the function execution unit includes:
[0090] A first function call subunit, configured to, if the target function does not carry a function parameter value, call the target function through a function call method corresponding to a Python interpreter to execute the target function to obtain a function execution result.
[0091] Optionally, the function execution unit includes:
[0092] The first function call subunit is configured to, if the function parameter value is carried in the target function, use the function parameter value as the method argument of the function call method corresponding to the Python interpreter to call the target function, so as to execute the target function and obtain the function execution result.
[0093] Optionally, the function execution unit includes:
[0094] The function execution subunit is configured to, if the target function is successfully executed, obtain the function execution result and display the function execution result in the code compilation area; and,
[0095] The code display subunit is configured to, if the target function fails to execute, locate the code position of the target function in the to-be-processed code according to the function name of the target function;
[0096] The position update subunit is configured to update the current display area position of the code compilation area to the code position.
[0097] Optionally, the function execution module 302 includes:
[0098] The close function call unit is configured to, if the interactive function component is a close function component, call the close component function corresponding to the close function component through the function call method corresponding to the Python interpreter;
[0099] The interface close unit is configured to execute the close component function. If the component close function is successfully executed, close the target interactive interface and end the program execution; and,
[0100] The error message generation unit is configured to, if the close component function fails to execute, generate an execution error message, close the target interactive interface, end the program execution, and display the execution error message in the code compilation area.
[0101] The interface interaction device based on Python provided by the embodiments of the present invention can execute the interface interaction method based on Python provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0102] Embodiment 4
[0103] Figure 4The structural schematic diagram of an electronic device 10 that can be used to implement the embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0104] As Figure 4 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0105] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0106] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the Python-based interface interaction method.
[0107] In some embodiments, the Python-based interface interaction method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the Python-based interface interaction method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the Python-based interface interaction method by any other suitable means (e.g., by means of firmware).
[0108] The various implementations of the systems and techniques described above in this document may be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: being implemented in one or more computer programs executable and / or interpretable on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0109] The computer program for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0110] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0111] To provide for interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0112] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0113] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0114] It should be understood that various forms of processes shown above can be used, steps can be reordered, added or deleted. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.
[0115] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A Python-based interface interaction method, characterized in that: include: In response to an interactive operation on an interface component in a target interactive interface, determining an interactive function component; The target interactive interface is obtained by performing interface rendering based on a scripting language character string; The script language character string is obtained by format conversion of the target character string; The target string is obtained by performing a template string extraction operation on the acquired code to be processed based on Python implementation; Determine and call the component function corresponding to the interactive function component, generate a function execution result, and display the execution result in the code compilation area to which the code to be processed belongs.
2. The method according to claim 1, characterized in that The determining and calling the component function corresponding to the interactive functional component and generating the function execution result includes: If the interactive functional component is a non-closed functional component, then according to the function name corresponding to the component attribute of the interactive functional component, a regular expression matching is performed on the function name in the script language character string to determine the target function; According to the objective function, a function execution result is generated.
3. The method according to claim 2, characterized in that Generating a function execution result according to the objective function includes: If the target function does not carry function parameter values, the target function is called through the function calling method corresponding to the Python interpreter to execute the target function to obtain the function execution result.
4. The method according to claim 2, characterized in that: Generating a function execution result according to the objective function includes: If the target function carries a function parameter value, the function parameter value is used as the method argument of the function call method corresponding to the Python interpreter to call the target function, so as to execute the target function and obtain the function execution result.
5. The method according to claim 2, characterized in that: Generating a function execution result according to the objective function includes: If the target function is executed successfully, a function execution result is obtained and displayed in the code compilation area; and, If the target function fails to execute, locating the code position of the target function in the code to be processed according to the function name of the target function; The current display area position of the code compilation area is updated to the code position.
6. The method according to claim 1, characterized in that The determining and calling the component function corresponding to the interactive functional component and generating the function execution result includes: If the interactive function component is a closing function component, calling the closing component function corresponding to the closing function component through the function calling method corresponding to the Python interpreter; Executing the component closing function, if the component closing function is successfully executed, closing the target interactive interface and ending the program execution; and, If the closing component function fails to execute, an execution error message is generated, the target interactive interface is closed, the program execution ends, and the execution error message is displayed in the code compilation area.
7. A Python-based interface interaction device, characterized in that: include: An interactive component determination module, used to determine an interactive function component in response to an interactive operation on an interface component in a target interactive interface; The target interactive interface is obtained by performing interface rendering based on a scripting language character string; The script language character string is obtained by format conversion of the target character string; The target string is obtained by performing a template string extraction operation on the acquired code to be processed based on Python implementation; The function execution module is used to determine and call the component function corresponding to the interactive function component, generate a function execution result, and display the execution result in the code compilation area to which the code to be processed belongs.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the Python-based interface interaction method described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the Python-based interface interaction method described in any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the Python-based interface interaction method according to any one of claims 1 to 6.