国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
2-Installation of?Streamlit module
?
3-Running Streamlit Application
4-Streamlit Basic commands
5-Display multimedia?
6-Input widgets
7-Display progress and status
8-Sidebar and container
Sidebar
Container
10-Display a DataFrame
Home Backend Development Python Tutorial Getting to know Python Streamlit Web Framework

Getting to know Python Streamlit Web Framework

Dec 15, 2024 pm 04:09 PM

Getting to know Python Streamlit Web Framework

Hi, Community!

In this article, I will introduce Python Streamlit Web Framework.

Below, you can find the topics we will cover:

  • 1-Introduction to Streamlit Web Framework
  • 2-Installation of?Streamlit module
  • 3-Running Streamlit Application
  • 4-Streamlit Basic commands
  • 5-Display multimedia?
  • 6-Input widgets
  • 7-Display progress and status
  • 8-Sidebar and container
  • 9-Data Visualization
  • 10-Display a DataFrame

?

So, let's start with the first topic.
1-Introduction to Python Streamlit?Web Framework?

Streamlit?is an open-source Python framework that allows data scientists and machine learning engineers to create interactive web applications quickly and easily.
With its simple syntax and effortless integration with popular data science libraries, Streamlit has become the front-runner for prototyping and sharing projects.

For more details please view Streamit Documentations

Getting to know Python Streamlit Web Framework

2-Installation of?Streamlit module

Before we start building our Streamlit Web Application, we need to install the module using the pip package installer.

To install Streamlit, run the following command:

pip install streamlit

Getting to know Python Streamlit Web Framework

Below there is the command to test the installation:?

streamlit hello

Getting to know Python Streamlit Web Framework


When you type the command mentioned above in the terminal, the following page should open automatically:

Getting to know Python Streamlit Web Framework

?

3-Running Streamlit Application

Working with Streamlit is straightforward. First, you sprinkle a few Streamlit commands into a normal Python script, then you run it with?streamlit run:

pip install streamlit

As soon as you run the script, a local Streamlit server will spin up and your app will open in a new tab in your default web browser. ?Please note that the app is your canvas, where you will draw charts, texts, widgets, tables, and more.

Another way of running Streamlit is doing so as a Python module. This can come in handy when configuring an IDE, e.g., PyCharm to work with Streamlit:

streamlit hello

Remember to save the source file whenever you wish to update your app. When you do so, Streamlit detects a change if any, and asks you whether you want to rerun your app. Select "Always rerun" at the top-right of your screen to automatically update your app each time you modify its source code. It will allow you to work in a fast interactive loop: you type some code, save it, try it out live, then type some more code, save it, try it out, and so on until you are happy with the results. This tight loop between coding and viewing results live is one of the ways Streamlit makes your life easier.

4-Streamlit Basic commands

Display texts with Streamlit

st.write(): This function adds anything from formatted strings to charts in Matplotlib figures, Altair charts, Plotly figures, data frames, Keras models, and others to a web app.

Let's create main.py file below:

streamlit run your_python_file.py 

Run the main.py file by operating the following command:

python -m streamlit run your_python_file.py

Getting to know Python Streamlit Web Framework


st.title(): This function allows you to add the title to the app.?
st.header(): This function is used to assign the header of a section.
st.markdown(): This function is utilized to set a markdown of a section.?
st.subheader(): This function is employed to set the sub-header of a section.
st.caption(): This function is used to write captions.
st.code():?This function is utilized to set a code.??
st.latex(): This function displays mathematical expressions formatted as LaTeX.?

import streamlit as st

st.write("Hello ,let's learn how to build a streamlit app together")

Getting to know Python Streamlit Web Framework

5-Display multimedia?

Below we listed some functions to display images, videos, and audio files.

st.image(): This function is employed to depict an image.
st.audio(): This function is utilized?to display an audio.?
st.video(): This function is used to show a video.

streamlit run main.py

Getting to know Python Streamlit Web Framework

6-Input widgets

Widgets are the most significant user interface components. Streamlit has various widgets that allow you to build interactivity directly into your apps with buttons, sliders, text inputs, and more.

st.checkbox(): This function returns a Boolean value. When the box is checked, it returns a True value. Otherwise, it sends back a False value.
st.button(): This function is used to display a button widget.?
st.radio(): This function exhibits a radio button widget.?
st.selectbox(): This function is utilized to demonstrate a select widget.?
st.multiselect(): This function is used to display a multi select widget.?
st.select_slider(): This function is used to display a select slider widget.?
st.slider(): This function is used to display a slider widget.

pip install streamlit

Getting to know Python Streamlit Web Framework

st.number_input(): This function displays a numeric input widget.
st.text_input(): This function exhibits a text input widget.
st.date_input(): This function reveals a date input widget to choose a date.
st.time_input(): This function exposes a time input widget to select a time.
st.text_area(): This function shows a text input widget with more than a line of text.
st.file_uploader(): This function is operated to demonstrate a file uploader widget.
st.color_picker(): This function is operated to demonstrate a file uploader widget.

streamlit hello

Getting to know Python Streamlit Web Framework

7-Display progress and status

At this point, we will explain how to add a progress bar and such status messages as error and success to our app.

st.balloons(): This function is used to display balloons for celebration.?
st.progress(): This function is utilized to show a progress bar.?
st.spinner(): This function demonstrates a temporary waiting message during execution.

streamlit run your_python_file.py 

Getting to know Python Streamlit Web Framework

st.success(): This function exhibits a success message.
st.error(): This function is used to demonstrate an error message.?
st.warning(): This function is utilized to display a warning message.
st.info(): This function reveals an informational message.
st.exception(): This function is operated to show an exception message.

pip install streamlit

Getting to know Python Streamlit Web Framework

8-Sidebar and container

We can additionally create a sidebar or a container on your page to organize your app. The hierarchy and arrangement of pages on your app can have a huge impact on your user experience. Organizing your content allows visitors to understand your site better and navigate it easier. It also helps them find what they are looking for faster and increases the likelihood that they will return.?

Sidebar

Passing an element to?st.sidebar()?will pin this element to the left, allowing users to focus on the content making your app more organized and easier to deal with.

streamlit hello

Getting to know Python Streamlit Web Framework

Container

st.container()?is employed to construct an invisible container where you can put elements creating a useful arrangement and hierarchy.

streamlit run your_python_file.py 

Getting to know Python Streamlit Web Framework

python -m streamlit run your_python_file.py

Getting to know Python Streamlit Web Framework

9-Data Visualization

Data visualization simplifies telling stories by curating data into a more straightforward format, highlighting the trends and outliers. A good visualization conveys a narrative, removing the noise from data and emphasizing the valuable information. However, it is way more complicated than just dressing up a graph to make it look better or slapping on an infographic's "info" part.
Effective data visualization is a delicate balancing act between form and function. A plain graph could be too boring to draw attention or communicate a powerful message, whereas the most stunning visualization could fail to deliver the right idea. The data and visuals need to work together. However, combining great analysis with excellent storytelling is an art.?

st.pyplot(): This function is used to display a matplotlib.pyplot figure.

pip install streamlit

Getting to know Python Streamlit Web Framework

st.line_chart(): This function is utilized to show a line chart.

streamlit hello

Getting to know Python Streamlit Web Framework

st.bar_chart(): This function is employed to exhibit a bar chart.

streamlit run your_python_file.py 

Getting to know Python Streamlit Web Framework

st.map(): This function displays maps in the app. However, it requires the values of latitude and longitude which cannot be null/NA.

python -m streamlit run your_python_file.py

Getting to know Python Streamlit Web Framework

10-Display a DataFrame

st.dataframe(): This command shows a DataFrame as an interactive table. It works with a variety of collection-like and DataFrame-like object types.

import streamlit as st

st.write("Hello ,let's learn how to build a streamlit app together")

Getting to know Python Streamlit Web Framework

You can also pass a Pandas Styler object to change the style of the rendered DataFrame:

streamlit run main.py

Getting to know Python Streamlit Web Framework


Summary

In this article, after introducing the Streamlit web framework, I demonstrated how to install Streamlit and run the application. We also explored some basic commands, widgets, and data visualization functionality.

In my next article, we will create a Streamlit web application to connect to the IRIS dataset and explore advanced concepts of Streamlit together.

Thanks

The above is the detailed content of Getting to know Python Streamlit Web Framework. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Polymorphism in python classes Polymorphism in python classes Jul 05, 2025 am 02:58 AM

Polymorphism is a core concept in Python object-oriented programming, referring to "one interface, multiple implementations", allowing for unified processing of different types of objects. 1. Polymorphism is implemented through method rewriting. Subclasses can redefine parent class methods. For example, the spoke() method of Animal class has different implementations in Dog and Cat subclasses. 2. The practical uses of polymorphism include simplifying the code structure and enhancing scalability, such as calling the draw() method uniformly in the graphical drawing program, or handling the common behavior of different characters in game development. 3. Python implementation polymorphism needs to satisfy: the parent class defines a method, and the child class overrides the method, but does not require inheritance of the same parent class. As long as the object implements the same method, this is called the "duck type". 4. Things to note include the maintenance

How do I write a simple 'Hello, World!' program in Python? How do I write a simple 'Hello, World!' program in Python? Jun 24, 2025 am 12:45 AM

The "Hello,World!" program is the most basic example written in Python, which is used to demonstrate the basic syntax and verify that the development environment is configured correctly. 1. It is implemented through a line of code print("Hello,World!"), and after running, the specified text will be output on the console; 2. The running steps include installing Python, writing code with a text editor, saving as a .py file, and executing the file in the terminal; 3. Common errors include missing brackets or quotes, misuse of capital Print, not saving as .py format, and running environment errors; 4. Optional tools include local text editor terminal, online editor (such as replit.com)

What are algorithms in Python, and why are they important? What are algorithms in Python, and why are they important? Jun 24, 2025 am 12:43 AM

AlgorithmsinPythonareessentialforefficientproblem-solvinginprogramming.Theyarestep-by-stepproceduresusedtosolvetaskslikesorting,searching,anddatamanipulation.Commontypesincludesortingalgorithmslikequicksort,searchingalgorithmslikebinarysearch,andgrap

What is list slicing in python? What is list slicing in python? Jun 29, 2025 am 02:15 AM

ListslicinginPythonextractsaportionofalistusingindices.1.Itusesthesyntaxlist[start:end:step],wherestartisinclusive,endisexclusive,andstepdefinestheinterval.2.Ifstartorendareomitted,Pythondefaultstothebeginningorendofthelist.3.Commonusesincludegetting

Python `@classmethod` decorator explained Python `@classmethod` decorator explained Jul 04, 2025 am 03:26 AM

A class method is a method defined in Python through the @classmethod decorator. Its first parameter is the class itself (cls), which is used to access or modify the class state. It can be called through a class or instance, which affects the entire class rather than a specific instance; for example, in the Person class, the show_count() method counts the number of objects created; when defining a class method, you need to use the @classmethod decorator and name the first parameter cls, such as the change_var(new_value) method to modify class variables; the class method is different from the instance method (self parameter) and static method (no automatic parameters), and is suitable for factory methods, alternative constructors, and management of class variables. Common uses include:

Python Function Arguments and Parameters Python Function Arguments and Parameters Jul 04, 2025 am 03:26 AM

Parameters are placeholders when defining a function, while arguments are specific values ??passed in when calling. 1. Position parameters need to be passed in order, and incorrect order will lead to errors in the result; 2. Keyword parameters are specified by parameter names, which can change the order and improve readability; 3. Default parameter values ??are assigned when defined to avoid duplicate code, but variable objects should be avoided as default values; 4. args and *kwargs can handle uncertain number of parameters and are suitable for general interfaces or decorators, but should be used with caution to maintain readability.

How do I use the csv module for working with CSV files in Python? How do I use the csv module for working with CSV files in Python? Jun 25, 2025 am 01:03 AM

Python's csv module provides an easy way to read and write CSV files. 1. When reading a CSV file, you can use csv.reader() to read line by line and return each line of data as a string list; if you need to access the data through column names, you can use csv.DictReader() to map each line into a dictionary. 2. When writing to a CSV file, use csv.writer() and call writerow() or writerows() methods to write single or multiple rows of data; if you want to write dictionary data, use csv.DictWriter(), you need to define the column name first and write the header through writeheader(). 3. When handling edge cases, the module automatically handles them

Explain Python generators and iterators. Explain Python generators and iterators. Jul 05, 2025 am 02:55 AM

Iterators are objects that implement __iter__() and __next__() methods. The generator is a simplified version of iterators, which automatically implement these methods through the yield keyword. 1. The iterator returns an element every time he calls next() and throws a StopIteration exception when there are no more elements. 2. The generator uses function definition to generate data on demand, saving memory and supporting infinite sequences. 3. Use iterators when processing existing sets, use a generator when dynamically generating big data or lazy evaluation, such as loading line by line when reading large files. Note: Iterable objects such as lists are not iterators. They need to be recreated after the iterator reaches its end, and the generator can only traverse it once.

See all articles