Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does python calculate the number of times

Shulou Source: shulou.com Published: 2022-05-31 11:13:57 09月12日 Update

This article mainly explains "how to calculate the number of times by python". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how python calculates the number of times".

The details are as follows:

Count () syntax

Str.count (sub, start= 0 (string))

Parameter description:

Sub: substring for search

Start: the position where the string starts the search. The default is the first character, and the index value of the first character is 0.

End: the position in the string where the search ends. The index of the first character in the character is 0, and the default is the last position of the string.

Example:

#! / usr/bin/python

# www.xieniao.com

Str = "this is string example.wowning examples!"

Sub = "I"

Print "str.count (sub, 4,40):", str.count (sub, 4,40)

Sub = "wow"

Print "str.count (sub):", str.count (sub)

Output result:

Str.count (sub, 4,40): 2

Str.count (sub): 1

At this point, I believe you have a deeper understanding of "how to calculate the number of times of python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Characters strings times locations content search indexing learning practicality deeper interests parameters practicality practicality simplicity of operation methods more friends examples results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL MariaDB macOS Docker