


python variable type - usage of python string str() (example)
In this article, I will talk about the python string str() in the standard numeric type in python. I hope it can help you who have just come into contact with python.
python string (String):
Python string is a string of characters composed of numbers, letters, and underscores. It can generally be recorded as follows:
1 |
|
(String is a data type that represents text in programming languages)
Python strings have two order of values:
1. From left to The right index starts from 0 by default, and the maximum range is 1 less than the string length.
2. The right-to-left index starts with -1 by default, and the maximum range is the beginning of the string.
If you want to take a section of string from a string, you can use [head subscript: tail subscript] to intercept the desired string, where the head subscript is calculated from 0. It can be a positive or negative number. If the tail subscript is empty, it means the head and tail are obtained. ([Head subscript: Tail subscript] The intercepted string includes the characters in the table below the head, but does not include the characters in the tail subscript. The character before the number written in the tail subscript is taken.) It is possible to just say it An unconvincing example is as follows:
1 2 3 4 5 |
|
The output result of the above example is:
1 |
|
When using colon-separated strings, python returns a new object, and the result contains the following For contiguous content marked by an offset, the left edge is inclusive of the lower border.
The above result contains the value b of s[1], and the maximum range obtained does not include the tail subscript, which is the value f of s[5].
The plus sign ( ) is the string concatenation operator, and the asterisk (*) is the repeating operation . The following example:
1 2 3 4 5 6 7 8 9 10 11 |
|
The results of the above example are as follows:
1 2 3 4 5 6 |
|
The above content is some examples and applications of python strings. I hope to provide some help to friends who have just come into contact with python.
The above is the detailed content of python variable type - usage of python string str() (example). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

Fastapi ...

Using python in Linux terminal...

Understanding the anti-crawling strategy of Investing.com Many people often try to crawl news data from Investing.com (https://cn.investing.com/news/latest-news)...
