How does python store each different substring in a string in a list?

Updated on technology 2024-02-26
7 answers
  1. Anonymous users2024-02-06

    The string is immutable, and the list is mutable.

    That is to say, once the meaning of the string is determined, it cannot be changed, but the list can.

    abc"d = a','b','c']'e'And.

    new_s = s + e'

    Moreover, immutable means that it can be used as a dictionary key, while mutable is not messy.

    Also, the approach to both things is different.

  2. Anonymous users2024-02-05

    list_tmp=f = open('file_','r'for i in :list list tmp It's okay to have a shift faction to argue the mu?

  3. Anonymous users2024-02-04

    If the file is not very large:

    def findstrinfile(filename, lookup):

    return lookup in open(filename,'rt').read()

    Dealing with large files:

    def findstrinlargefile(filename, lookup):

    with open(filename, 'rt') as handle:

    for ln in handle:

    if lookup in ln:

    return true

    else:return false

  4. Anonymous users2024-02-03

    You can use '' to split this string to get a list.

    For example, if your string input is stored in the variable test string, then test'') is a list of 3 elements, each of which is a string (without line breaks).

  5. Anonymous users2024-02-02

    >>>string = a_b_c_001a_b_c_002

    a_b_c_003'''

    >['a_b_c_001', a_b_c_002', a_b_c_003']

    String operation, the splitlines function splits the string into rows and returns a list.

  6. Anonymous users2024-02-01

    Separated by split. Or regular ...

    a=""a_b_c_001

    a_b_c_002

    a_b_c_003

    import re

    p="(n]+)n")

    result=;

    print result

    As a result, it was. [('a', b', c', 001'),a', b', c', 002'),a', b', c', 003')]

  7. Anonymous users2024-01-31

    print sum(map(ord,list(where str1 is the input string.

    Take ABC as an example:

    Turn all letters into lowercase ABC.

    list( turns the string into ['a', 'b', 'c']ord turns letters into ASCII numbers.

    map(ord,list(Turns all letters in the list into numbers [97,98,99].)

    sum.

    After summing, since the ascii of a is 97, each letter has to be subtracted by 96.

Related questions
5 answers2024-02-26

Add a field in Table 1 as a foreign key and Billno in Table 2 >>>More

7 answers2024-02-26

Do it by your train of thought.

Method 1. string strnumber="200m"; >>>More

8 answers2024-02-26

Incorporating moral education into a day's activities is the most effective way to do it in everyday lifeEarly childhood teachersIt is necessary to be good at infiltrating the cultivation of children's good living habits and behavioral habits into preschool education. >>>More

15 answers2024-02-26

It's very simple, select all the text toolbar** Convert text to** OK, then it will show the Chinese and English separately arrangement**, and then select all the text, click the toolbar** Convert**Convert to text OK, then ** is gone. All that's left is a neat two-line line of text. This method is simple, but the disadvantage is that it is not easy to master, and there is a certain skill in adjusting the width of the column, which is not clear here. >>>More

10 answers2024-02-26

Horizontal top or top top of the page?

Hitting directly is horizontally topped. >>>More