Skip to content

Dev#1

Open
Crowiant wants to merge 2 commits intomasterfrom
Dev
Open

Dev#1
Crowiant wants to merge 2 commits intomasterfrom
Dev

Conversation

@Crowiant
Copy link
Owner

@Crowiant Crowiant commented Jun 4, 2020

No description provided.

dt_now = DT.date.today()
dt_yesterday = DT.timedelta(days=1)
dt_thirty_days = DT.timedelta(days=30)
return print(dt_now, (dt_now - dt_yesterday), (dt_now - dt_thirty_days))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты тут возвращаешь результат вызова print() . Это всегда None. Лучше возвращать из функции значение и принтить его там, где ты вызываешь функцию

В ней надо заменить pass на ваш код
"""
pass
with open('referat.txt', 'r', encoding='utf-8') as file_1:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Рассказывал об этом на созвоне. Пока ты находишься внутри with - файл держится открытым. Это не нужно, достаточно записать данные в переменную и работать с ней снаружи with

with open('referat.txt', 'r', encoding='utf-8') as file_1:
content = file_1.read()
len_of_file = len(content)
word_in_file = len(content.split())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

words*

len_of_file = len(content)
word_in_file = len(content.split())
replace_in_file = content.replace('.', '!')
list_for_write = [len_of_file, word_in_file, replace_in_file]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не надо в названии переменной писать ее тип, для этого есть аннотации типов

list_for_write = [len_of_file, word_in_file, replace_in_file]
with open('referat2.txt', 'a', encoding='utf-8') as file_2:
for arg in list_for_write:
file_2.write(f"{arg} \n")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

есть метод writelines, который принимает список строк для записи

writer = csv.DictWriter(file, fields, delimiter=';')
writer.writeheader()
for dictn in some_list:
writer.writerow(dictn)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже рассказывал на созвоне, есть метод writerows

import csv


list_of_dict = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Несодержательное название переменной

]


def main(some_list: list):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут тоже несодержательное название параметра

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments