Telegram Group & Telegram Channel
Прочитать произвольную строку из файла

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

И конечно же не обошлось без приветствия, вы специально заготовили несколько различных вариантов в файле text.txt:

Приветствую!
Здравствуйте!
Ку, здарова.
Добрый день!
Привет!

Чтобы вывести это на экран, может помочь функция getline из модуля linecache. В чем главное отличие этой функции от обычного метода чтения из файла? Функция getline кеширует все строчки файла в списке, так что следующие вызовы get_answer отработают моментально.

#linecache #file



tg-me.com/python_academy/857
Create:
Last Update:

Прочитать произвольную строку из файла

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

И конечно же не обошлось без приветствия, вы специально заготовили несколько различных вариантов в файле text.txt:

Приветствую!
Здравствуйте!
Ку, здарова.
Добрый день!
Привет!

Чтобы вывести это на экран, может помочь функция getline из модуля linecache. В чем главное отличие этой функции от обычного метода чтения из файла? Функция getline кеширует все строчки файла в списке, так что следующие вызовы get_answer отработают моментально.

#linecache #file

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/857

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

Python Academy from sa


Telegram Python Academy
FROM USA