How Can We Help?

Python 3 Programming

Python 3 Programming

mBlock-Python Editor support Python 3 programming. You can use it like other Python editors to create and run a Python 3 project.

This section uses a liquid chart as an example.

1. Install the Python library required.

In this example, the pyecharts library is required. For details about how to install a Python library, see “Install or Uninstall Python Libraries.”

2. Choose File > New project, and enter your code in the project file editing area.

Enter the following code:

from pyecharts import options as opts

from pyecharts.charts import Liquid, Page

from pyecharts.globals import SymbolType

import os

def liquid() -> Liquid:

c = (

Liquid()

.add(“lq”, [0.67, 0.30, 0.15])

.set_global_opts(title_opts=opts.TitleOpts(title=”Liquid”))

)

return c

liquid().render(‘liquid.html’)

os.system(“open liquid.html”)

3. Click Run.

An HTML file is generated in the Project Files area.

Open the file. You can see a dynamic liquid chart.

For more details about Python 3, see “Python Learning.”