0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
1

'Str' object is not callable

21.05.2022, 13:16. Показов 451. Ответов 4
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Форумчане, привет!

Извлекаю текст из ссылок между тегами a.
Выводится сообщение об ошибке:
HTML5
1
2
    for i in range(depth):
TypeError: 'str' object is not callable
Проверил тип переменной depth - integer.
Подскажите, пожалуйста, где ошибка?

Фрагмент html, который я обрабатываю:
Кликните здесь для просмотра всего текста

<tr>
<td>
<div class="flex">
<div class="flex-column pt1 mr3" style="width: 102px;">
<button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button">
Save
</button>
<button class="request-intro-button " type="button">
View
</button>
</div>
<a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ber-cu" style="height: 102px; width: 102px;">
<div style="position: relative; width: 102px; height: 102px;">
<img alt="Photo" class="humbnail listimage-container" height="102" src="To_files/12.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/>
</div>
</a>
<div class="pt1">
<div class="sn-tor-name-wrapper">
<div class="flex" style="align-items: center;">
<a href="https://bbb.com/fly/be-gs" style="line-height: 12px; margin-bottom: 3px; color: white;">
<strong class="sn-tor-name null">
Ber Cu
</strong>
</a>
</div>
<a href="https://bbb.com/firms/third-es">
A-ta-ta
</a>
<span class="sn-small-link hidden-xs null">
Se Ate
</span>
</div>
</div>
</div>
</td>
<td class="text-center relative">
<span class="text-center" style="cursor: pointer; margin: 0px auto;">
n/a
</span>
</td>
<td class="text-center pt2">
<div class="flex-column">
<div>
Black
</div>
<div class="">
Green 12
</div>
</div>
</td>
<td style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-en-rs">
MA
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-san-rs">
CA
</a>
</span>
</div>
</div>
</div>
</div>
</td>
<td class="" style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-bi-rs">
Bi
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-di-rs">
Di
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-ho-rs">
Ho Se
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
IT
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-me-rs">
M Di
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
Other
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+3
</span>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="flex">
<div class="flex-column pt1 mr3" style="width: 102px;">
<button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button">
Save
</button>
<button class="request-intro-button" type="button">
View
</button>
</div>
<a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/au-st" style="height: 102px; width: 102px;">
<div style="position: relative; width: 102px; height: 102px;">
<img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/133.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/>
</div>
</a>
<div class="pt1">
<div class="sn-tor-name-wrapper">
<div class="flex" style="align-items: center;">
<a href="https://bbb.com/fly/au-st" style="line-height: 12px; margin-bottom: 3px; color: white;">
<strong class="sn-tor-name null">
Au St
</strong>
</a>
</div>
<a href="https://bbb.com/f/san-ur">
San V
</a>
<span class="sn-small-link hidden-xs null">
Si Ass
</span>
</div>
</div>
</div>
</td>
<td class="text-center relative">
<span class="text-center" style="cursor: pointer; margin: 0px auto;">
d/a
</span>
</td>
<td class="text-center pt2">
<div class="flex-column">
<div>
G0 1.2
</div>
<div class="">
12 - 14
</div>
</div>
</td>
<td style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
CA
</a>
</span>
</div>
</div>
</div>
</div>
</td>
<td class="" style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-di-rs">
Di Ha
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
Ho Se
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
HI
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-me-rs">
Mi Se
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
Other
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+2
</span>
</div>
</div>
</td>
</tr>


Мой код:
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from bs4 import BeautifulSoup
 
with open(r"C:\777\Scraping\testfile.txt", 'r', encoding='utf-8') as f:
    quotes = f.read()
    f.close()
 
soup = BeautifulSoup(quotes, "html.parser")
reestrs = soup.find_all('tr')
print(len(reestrs))
#i = len(reestrs)
#print(soup.prettify())
 
data = []
data1 = []
 
for reestr in reestrs:
    name1 = reestr.find('div', class_='sn-tor-name-wrapper').find_all('a')[0].find('strong', class_='sn-tor-name null').text
    spot = reestr.find('td', class_='text-center pt2').find_all('div')[1].text
    range = reestr.find('td', class_='text-center pt2').find_all('div')[2].text
    sec = reestr.find('div', class_='sn-clamp').find_all('a')
    depth = len(sec)
    print(type(depth))
    for i in range(depth):
        long = sec[i].text
        data1.append(long)
    print(data1)
 
    data.append([name1, spot, range, sec, long])
 
print(data)
И еще вопрос: как вывести все данные в одной строке (сцепить [data + data1], чтобы одни выводились одной строкой для каждой конструкции внутри тега <tr>?

Благодарю.
0
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
21.05.2022, 13:16
Ответы с готовыми решениями:

'str' object is not callable Почему?
Я конечно туплю но не думал что на столько Пишу типа Адресную книгу При выборе действия...

TypeError: 'str' object is not callable
Здравствуйте! Первый раз встретился с данной ошибкой, поэтому не бейте. def...

TypeError: 'str' object is not callable. Как исправить?
import string file = open(&quot;input.txt&quot;, &quot;r&quot;) db = file.readlines() file.close() file =...

TypeError: 'str' object is not callable. Как исправить? - Python
import time, socket, threading, requests, urllib, socks def thread(numthreads, attack): ...

Как исправить ошибку TypeError: 'str' object is not callable?
Как исправить ошибку типа объекта. try: WebDriverWait(chrome, 60).until( ...

4
Эксперт PythonЭксперт Java
19509 / 11049 / 2931
Регистрация: 21.10.2017
Сообщений: 23,302
21.05.2022, 15:16 2
Цитата Сообщение от MaxGal
range = reestr.find(
За такие имена переменных нужно предавать анафеме
2
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
21.05.2022, 18:16  [ТС] 3
Блин...
Это просто усталость: не могу сосредоточиться. И внутренний голос ведь говорил - что-то не то с именем. Блин...
И запостил когда, мелькнула мысль: "А почему range в коде зеленым выделило?". Блин...
Благодарю.

А как организовать корректный вывод в строку?
1.[name1, spot, ran, [text1, text2, text3]] (где text1(2,3,4,5) - текст из ссылок (между тегами a)).
2.[name1, spot, ran, [text1, text2, text3, text4, text5]]
и т.д.
А то сейчас такое печатает...
0
Эксперт PythonЭксперт Java
19509 / 11049 / 2931
Регистрация: 21.10.2017
Сообщений: 23,302
21.05.2022, 18:51 4
Цитата Сообщение от MaxGal Посмотреть сообщение
сцепить [data + data1]
Почитай про join()
0
0 / 0 / 0
Регистрация: 24.10.2015
Сообщений: 142
21.05.2022, 23:24  [ТС] 5
Сорри, я не совсем корректно сформулировал второй вопрос.
Есть один цикл, который извлекает данные между <tr>.
Есть второй, цикл, вложенный в этот. Он должен выбирать информацию меду тегами а в блоках <div class="sn-clamp">.
Каждый из них по отдельности работает отлично.
А когда я их соединяю, они не корректно соединяют данные.

Вот мой код:
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from bs4 import BeautifulSoup
 
with open(r"C:\777\Scraping\testfile-1.txt", 'r', encoding='utf-8') as f:
    quotes = f.read()
    f.close()
 
soup = BeautifulSoup(quotes, "html.parser")
reestrs = soup.find_all('tr')
print(len(reestrs))
#i = len(reestrs)
#print(soup.prettify())
 
data = []
data1 = []
 
for reestr in reestrs:
    name1 = reestr.find('div', class_='sn-tor-name-wrapper').find_all('a')[0].find('strong', class_='sn-tor-name null').text
    try:
        name2 = reestr.find('div', class_='sn-tor-name-wrapper').find_all('a')[1].text
    except IndexError:
        text = 'none'
    try:
        posit = reestr.find('div', class_='sn-tor-name-wrapper').find('span', class_='sn-small-link hidden-xs null').text
    except AttributeError:
        posit = 'none'
    spot = reestr.find('td', class_='text-center pt2').find_all('div')[1].text
    ran = reestr.find('td', class_='text-center pt2').find_all('div')[2].text
    sec = reestr.find('div', class_='sn-clamp').find_all('a')
    depth = len(sec)
    # print(type(depth))
    for i in range(depth):
        long = sec[i].text
        data1.append(long)
#print(data1)
#
    data = [name1, name2, posit, spot, ran]
data.append(data1)
#
#
#    data.append([name1, link1, name2, link2, posit, spot, ran])
#     #data.append([name1, spot, ran, long])
#     # data.append([name1, spot, ran])
#
print(data)
А вот мой html:
Кликните здесь для просмотра всего текста

<tr>
<td>
<div class="flex">
<div class="flex-column pt1 mr3" style="width: 102px;">
<button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button">
Save
</button>
<button class="request-intro-button " type="button">
View
</button>
</div>
<a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ber-cu" style="height: 102px; width: 102px;">
<div style="position: relative; width: 102px; height: 102px;">
<img alt="Photo" class="humbnail listimage-container" height="102" src="To_files/12.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/>
</div>
</a>
<div class="pt1">
<div class="sn-tor-name-wrapper">
<div class="flex" style="align-items: center;">
<a href="https://bbb.com/fly/be-gs" style="line-height: 12px; margin-bottom: 3px; color: white;">
<strong class="sn-tor-name null">
Data_1.1
</strong>
</a>
</div>
<a href="https://bbb.com/firms/third-es">
Data_1.2
</a>
<span class="sn-small-link hidden-xs null">
Data_1.3
</span>
</div>
</div>
</div>
</td>
<td class="text-center relative">
<span class="text-center" style="cursor: pointer; margin: 0px auto;">
n/a
</span>
</td>
<td class="text-center pt2">
<div class="flex-column">
<div>
1.C1
</div>
<div class="">
1.C1 - C2
</div>
</div>
</td>
<td style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
In
<a href="https://bbb.com/r-lists/top-en-rs">
1.1.1
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-san-rs">
1.1.2
</a>
</span>
</div>
</div>
</div>
</div>
</td>
<td class="" style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/16.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
In
<a href="https://bbb.com/r-lists/top-bi-rs">
1,2,1
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-di-rs">
1,2,2
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-ho-rs">
1.2.3
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-he-rs">
1.2.4
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-me-rs">
1.2.5
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-sa-rs">
1.2.6
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+3
</span>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="flex">
<div class="flex-column pt1 mr3" style="width: 102px;">
<button class="sn-dark-white-button " label="Save" style="margin-bottom: 5px;" type="button">
Save
</button>
<button class="request-intro-button" type="button">
View
</button>
</div>
<a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/au-st" style="height: 102px; width: 102px;">
<div style="position: relative; width: 102px; height: 102px;">
<img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/133.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/>
</div>
</a>
<div class="pt1">
<div class="sn-tor-name-wrapper">
<div class="flex" style="align-items: center;">
<a href="https://bbb.com/fly/au-st" style="line-height: 12px; margin-bottom: 3px; color: white;">
<strong class="sn-tor-name null">
Data_2.1
</strong>
</a>
</div>
<a href="https://bbb.com/f/san-ur">
Data_2.2
</a>
<span class="sn-small-link hidden-xs null">
Data_2.3
</span>
</div>
</div>
</div>
</td>
<td class="text-center relative">
<span class="text-center" style="cursor: pointer; margin: 0px auto;">
d/a
</span>
</td>
<td class="text-center pt2">
<div class="flex-column">
<div>
2.C1
</div>
<div class="">
2.C1 - C2
</div>
</div>
</td>
<td style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
2.1.1
</a>
</span>
</div>
</div>
</div>
</div>
</td>
<td class="" style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/26.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
It
<a href="https://bbb.com/r-lists/top-di-rs">
2.2.1
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
2.2.2
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
2.2.3
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-me-rs">
2.2.4
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
2.2.5
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+2
</span>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="flex">
<div class="flex-column pt1 mr3" style="width: 102px;">
<button class="sn-dark-white-button" label="Save" style="margin-bottom: 5px;" type="button">
Save
</button>
<button class="request-intro-button" type="button">
View
</button>
</div>
<a class="flex-column pt1 mr3 items-center" href="https://bbb.com/fly/ja-ko" style="height: 102px; width: 102px;">
<div style="position: relative; width: 102px; height: 102px;">
<img alt="Photo" class="thumbnail listimage-container" height="102" src="To_files/09.jpg" style="object-fit: cover; height: 102px; width: 102px;" width="102"/>
</div>
</a>
<div class="pt1">
<div class="sn-tor-name-wrapper">
<div class="flex" style="align-items: center;">
<a href="https://bbb.com/fly/ja-ko" style="line-height: 12px; margin-bottom: 3px; color: white;">
<strong class="sn-tor-name null">
Data_3.1
</strong>
</a>
</div>
<a href="https://bbb.com/f/ar-rs">
Data_3.2
</a>
<span class="sn-small-link hidden-xs null">
Data_3.3
</span>
</div>
</div>
</div>
</td>
<td class="text-center relative">
<span class="text-center" style="cursor: pointer; margin: 0px auto;">
n/a
</span>
</td>
<td class="text-center pt2">
<div class="flex-column">
<div>
3.C1
</div>
<div class="">
3.C1 - C2
</div>
</div>
</td>
<td style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/36.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
In
<a href="https://bbb.com/r-lists/top-sa-rs">
3.1.1
</a>
,
</span>
<span>

</span>
<span>
In
<a href="https://bbb.com/r-lists/top-se-rs">
3.1.2
</a>
,
</span>
<span>
In
<a href="https://bbb.com/r-lists/top-mi-rs">
3.1.3
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+2
</span>
</div>
</div>
</td>
<td class="" style="max-width: 400px;">
<div>
<div style="position: relative;">
<div class="sn-clamp" style="font-size: 12px; line-height: 1.4; max-height: 50.4px; -webkit-line-clamp: 3; padding-right: 20px;">
<iframe aria-hidden="true" aria-label="resize-listener" frameborder="0" src="To_files/366.htm" style="display: block; opacity: 0; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;" tabindex="-1">
</iframe>
<div style="position: relative;">
<span>
Invest
<a href="https://bbb.com/r-lists/top-bi-rs">
3.2.1
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-co-rs">
3.2.2
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-di-rs">
3.2.3
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
3.2.4
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-he-rs">
3.2.5
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-me-rs">
3.2.6
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-ph-rs">
3.2.7
</a>
,
</span>
<span>
It
<a href="https://bbb.com/r-lists/top-sa-rs">
3.2.8
</a>
</span>
</div>
</div>
<span class="sn-pill" style="bottom: -5px; right: 0px;">
+5
</span>
</div>
</div>
</td>
</tr>


Должно выводить так
[Data_1.1, Data_1.2, Data_1.3, 1.C1, 1.C1 - C2, [1.1.1, 1.1.2]]
[Data_2.1, Data_2.2, Data_2.3, 2.C1, 2.C1 - C2, [2.1.1]]
[Data_3.1, Data_3.2, Data_3.3, 3.C1, 3.C1 - C2, [3.1.1, 3.1.2. 3.1.3]]

Каждый цикл в отдельности выводит данные правильно (если закомментить строки и посмотреть). А совместно выводит так:
['\n Data_3.1\n ', '\n Data_3.2\n', '\n Data_3.3\n', '\n 3.C1\n', '\n 3.C1 - C2\n ', ['\n 1.1.1\n', '\n 1.1.2\n', '\n 2.1.1\n ', '\n 3.1.1\n ', '\n 3.1.2\n', '\n 3.1.3\n ']]
Наверное, что-то с вложенностью цикла.
Уже и так и сяк пробовал. Не хватает опыта.
0
21.05.2022, 23:24
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
21.05.2022, 23:24
Помогаю со студенческими работами здесь

Внезапный лишний аргумент: str ('str' object has no attribute 'Name')
Здравствуйте, уважаемые форумчане! Создаю простейшее приложение на Python: класс и его...

'int' object is not callable
res = 'zzzzz' dict = {} with open('file.txt', 'r') as inpf: s =...

'dict' object is not callable
Добрый день! Это не вопрос, просто хочу поделиться. Возникло такая ситуация при попытке...

'float' object is not callable
import math a = int(input()) b = int(input()) c = int(input()) p = (a + b + c) / 2 S =...

TypeError: 'int' object is not callable
Начал изучать питон но столкнулся с проблемой. def d(): x=int(input(&quot;Введите: &quot;))...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Опции темы

Новые блоги и статьи
Как проводить научные вычисления на Python
InfoMaster 15.01.2025
Python стал одним из наиболее востребованных языков программирования в области научных вычислений благодаря своей простоте, гибкости и обширной экосистеме специализированных библиотек. Научные. . .
Создание игры типа Minecraft на PyGame/Python: пошаговое руководство
InfoMaster 15.01.2025
В данном руководстве мы рассмотрим процесс создания игры в стиле Minecraft с использованием библиотеки PyGame на языке программирования Python. Этот проект идеально подходит как для начинающих. . .
Как создать свою первую игру в стиле Doom на Unreal Engine
InfoMaster 15.01.2025
Разработка шутера от первого лица в стиле классического Doom представляет собой увлекательное путешествие в мир игрового программирования, где сочетаются творческий подход и технические навыки. . . .
Параллельное программировани­е: основные технологии и принципы
InfoMaster 15.01.2025
Введение в параллельное программирование Параллельное программирование представляет собой фундаментальный подход к разработке программного обеспечения, который позволяет одновременно выполнять. . .
Как написать микросервис на C# с Kafka, MediatR, Redis и GitLab CI/CD
InfoMaster 15.01.2025
В современной разработке программного обеспечения микросервисная архитектура стала стандартом де-факто для создания масштабируемых и гибких приложений. Этот подход позволяет разделить сложную систему. . .
Что такое CQRS и как это реализовать на C# с MediatR
InfoMaster 15.01.2025
Концепция CQRS и её роль в современной разработке В современном мире разработки программного обеспечения архитектурные паттерны играют ключевую роль в создании масштабируемых и поддерживаемых. . .
Как настроить CI/CD с Azure DevOps
InfoMaster 15.01.2025
CI/ CD, или непрерывная интеграция и непрерывное развертывание, представляет собой современный подход к разработке программного обеспечения, который позволяет автоматизировать и оптимизировать процесс. . .
Как настроить CI/CD с помощью Jenkins
InfoMaster 15.01.2025
Введение в CI/ CD и Jenkins В современной разработке программного обеспечения непрерывная интеграция (CI) и непрерывная доставка (CD) стали неотъемлемыми элементами процесса создания качественных. . .
Как написать микросервис на Go/Golang с Kafka, REST и GitHub CI/CD
InfoMaster 14.01.2025
Определение микросервиса, преимущества использования Go/ Golang Микросервис – это архитектурный подход к разработке программного обеспечения, при котором приложение состоит из небольших, независимо. . .
Как написать микросервис с нуля на C# с RabbitMQ, CQRS, Swagger и CI/CD
InfoMaster 14.01.2025
В современном мире разработки программного обеспечения микросервисная архитектура стала стандартом де-факто для создания масштабируемых и гибких приложений. Этот архитектурный подход предполагает. . .
Как создать интернет-магазин на PHP и JavaScript
InfoMaster 14.01.2025
В современном мире электронная коммерция стала неотъемлемой частью бизнеса. Создание собственного интернет-магазина открывает широкие возможности для предпринимателей, позволяя достичь большей. . .
Как написать Тетрис на Ассемблере
InfoMaster 14.01.2025
Тетрис – одна из самых узнаваемых и популярных компьютерных игр, созданная в 1984 году советским программистом Алексеем Пажитновым. За прошедшие десятилетия она завоевала симпатии миллионы людей по. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru