Python Forum: Questions and Answers

#проект
#работа
#книга
#урок
#debug
#jupyter
#venv
#pip
#оптимизация
#интервью
#продвинутый
#новичок
#игра
#автоматизация
#базы_данных
#ии
#парсинг
#боты
#веб
#asyncio
#tkinter
#requests
#matplotlib
#pandas
#numpy
#flask
#django
#python3
#python2
#совет
#обсуждение
#пример
#ошибка
#помощь
#вопрос
#python
#метакласс
#асинхронность
#многопроцессорность
#многопоточность
#контекстный_менеджер
#assert
#logging
#исключение
#try_except
#итератор
#генератор
#строка
#кортеж
#множество
#словарь
#список
#полиморфизм
#инкапсуляция
#метод
#ооп
#декоратор
#lambda
#рекурсия
#функция
#match_case
#тернарный
#break_continue
#Циклы
#Условия
аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, python, вопрос, совет
How to divide all integers in the array into separate categories?

Good day! Interested in such a question.
Suppose that there is such a code:

  a =  line  ( range  ( 1 ,  11 ))   print  (a)     

he will display [1, 2, 3, 4, 5, 7, 8, 9, 9, 9, 9, 9, 9 10]

I have the question: is it possible to somehow divide the two-digit number 10 into two separate elements of the sheet, i.e. To make the leaf look like this:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0]

If the question is "" nafig "" in general, I can explain. b (they are set by the user), then calculate how many times certain numbers are found and out to the screen.
To determine the numbers, I use the function cub
(a la b = a.count (1) ), but of course the figure is only once (only once (which is only once (which is only once (which is only once (which is only once (which is only once (which is only once ( Sadly, but not surprising).
I hope for your advice. It is possible (and even most likely), there is a much easier way to solve this problem, but we are not looking for easy ways.

Thank you all for the detailed answers! I will test all the presented solutions!

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, пример, работа
Pyqt5 window with a transparent background

I want to create a window that has a transparent background inside.

I jumped over all the options. I invariably get a black background. The option with the transparency of the whole window works, but does not suit, since the well-visible frames and emptiness are needed.

Example of code:

   from   PyQT5.QTWIDGETS  Import  qpplication, QWIDGET  from  pyqt5  Importcore  class   example  ( qwidget ):   def   __ Init __  ( self ):   super  () .__ Init __ ()  self.initui ()   def   initui  ( self ):  self.setgeometry ( 300 ,  300 ,  300 ,  220 )  self.setwindowtitle ( '' example ')   Self.Settrt and class = ""> '' __ main __ ':   import  sys app = qpplication (sys.argv)  ex = example ()  ex theyslo ()  ()  sys.exit (app.exec _ ())   
аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, пример
Stop Thread when completing the main stream of the script

For example, I have the following code:

   def   loop :   While   true :   print  ( "" text "" )  Sleep ( 10 ) thread = Threading.thread (target = loop)     

how to make the stream stop after the completion of the program?

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ошибка
How to make a static property of the class in Python?

I try this:

   class   chantcodes :  _Chat =  'CHT'    @property    def   retu  seelf._chat    

if I use this:

   Print  (Chatcodes.chat +  'ANY_STR' )  

then an error appears:

unsuporteded Operand Type (S) for +: 'Property' and 'str'

How to create a static property?

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, вопрос, пример
Get a translation of the word from the Google Translate website in python

I have such a question that if there is a website Translate.google.com (for example). When you want to translate the word, you must enter it in the field and then it will give you the result. And now I have a question that if I want to get a translation of some word through Google Translate, how can I swear it so much through Python? Please tell me any libraries or articles, because I did not find it, I will be grateful. )

аватар форума question@mail.ru · 0000-00-00 00:00:00 · словарь, python, пример, ии
Is it possible to initialize class variables in the dictionary. Python3.8

Is it possible to somehow assign the values ​​of the class transferred to each variable in the dictionary. For example, the class has variables: a, b, c, d -, and I convey the dictionary to the designer of the class:

  Dictionary = { `` ""> 'b' :  5 ,  'a' :  2 ,  'c' :  45 }     

the designer should contact the variable class by the names of the keys to the dictionary and set these values ​​to them, while the keys can be arbitrary. DATA-HIGHLIGHTED = ""> class expain : def __ Init __ ( self, d: dict ): self.a, self.b, self.c = int # there should be a code to initiate variables transferred to dictionary if __name__ == '' __ main __ ': dictionary = {' 'b' 5 , 'a' : 2 , 'c' : 45 } ex = Example (dictionary) print (ex.b) # must deduce: "5" ".

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ии, работа
Python is in Path but does not start from CMD

installed Python for Visual Studio 2019. I also want to work with it from CMD. He added the way to the folder containing python.exe in the variable path . However, when restarting CMD and introduction of python , an invitation to the input appears again, and Windows launches its application store and offers to download Python.

I work on Windows 10 Pro.

аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, кортеж, python
Python, from a motorcade to a line

a motorcade {"" "34", "76", "0", "532"} how to pull out the numbers from this motorcade so that when the output does this form?

   34 ,  76 ,  0 ,  532      

I just have thoughts to put on the list, then pull out, but still have quotation marks, how to get rid of them? {, , "" "" 532 "} lst = [] for i in a: lst.append (i) print (lst) [ '' '`` ">' '' ' , '' 34 ', ' 0 ', ' '76' ]

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, пример, работа
Odd numbers on the segment

Two integers are given, a and b . b .
upd: Use the instruction if is prohibited!

Input:
Two whole numbers are presented: a and b a & le; b ), one in a line

Output:
Drive through a gap of all odd numbers on a given given segment

input data:

   1    10   

Eat data:

   1   3   5   7   9      

my code does not always work: for example, if a is a negative and negative and negative and negative and negative and negative and negative and negative Himatic.

Code:

  a =  int  ( input  ()) b =  int  ( input  ())   for  i  in   range  (a - (a +  1 ) %  2 , b %  2 ,  2 ): )  print  (i, end =  '' )   
аватар форума question@mail.ru · 0000-00-00 00:00:00 · метод
How to take the next message of the user Aiogram

In Telebot, this method looks like this Bot.register_next_step_handler

How to take the next message of the user in Aiogram?

аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ошибка, боты
The task is "minimum simple divider"

I just started to study Python on the Sirius platform. I was able to solve all other problems from the topic & laquo; While & raquo;, besides one task that does not allow me to go on the following topics. The task & laquo; the minimum simple divisor of the number & raquo;.

Condition: gives an integer that is no less than 2. Bring its smallest simple divisor. You can not use additional libraries (math, etc.)!

Input data: The whole positive number of n & lt; = 2*10 in the 9th degree.

Output: display the response to the task.

tried Decide by writing a code with While, but my answer is not counted, due to the program for too long. It is recommended that you organize a cycle that sorting out the dividers to the root from the n: While I*i & Lt; = N: , but I can’t understand how to do it.

my code Python (issues an error & laquo; the program was executed for too long and was interrupted & raquo; or & laquo; program; gives an error in the process of execution & raquo;):

  n =  int  ( input  ()) i =  2    when  i & lt; = n:   if%i! =  0 :  i +=  1    print  (i)     

I can not understand what the error is?

аватар форума question@mail.ru · 0000-00-00 00:00:00 · вопрос, пример
Coding when sending a message

Dmitry Dereyankin. Thank you very much for the example, easily realized it at home. But there is a problem. If msg = mimetext ('') contains only Latin, then everything is fine. But if it is Cyrillic, then there are problems with the encoding: a = "Plain" "Part = mimetext (a)

result: & Eth; & Plusmn; & Eth; & Raquo; & Ntilde; & Ntilde; & Hellip; & Eth; & Deg;

At the same time, the theme of the letter is normally displayed both by Latin and Cyrillic. Thank you in advance for the answer to the stupid noob question.

аватар форума question@mail.ru · 0000-00-00 00:00:00 · словарь, python, ошибка, пример, работа
Python 3 multidimensional dictionary

Studying Python 3.X, I went on the basics. Before that, I wrote on php.

now I decided to complete the plan:

  • read CSV
  • as the file lines read, process them and write them in an array, creating the desired structure
  • ...

    now My code

       import  csv  def   gene_name  ( gene, polfzm, genotype ):   retu   '_'  .join ([gene, polfzm, genotype]). strip (). Replace (, ) data = {} geenes = []   of   open  ( 'example-2.csv' ,  '`` )  as  file:  reader = csv.dictreader (File, Delimiter =  ';' )   for  row  in  reader:  group = row [ 'group' ]  person_id = row [ 'person_id' ]  ab = row [ '' genotype ']  name = gene_name (row [ 'gene_name' ], row [ 'polfzm_name' ], ab)  data [group] [name_id] = ab # arises Error      

    and there is a problem. If I understand correctly, then a word is suitable for storing my data in a structured form - data . In PHP, I could easily create the structure/attachment of the data [group] [person_id] [name] = ab . Immediately there is an error keyerror: '3'

    what's the mistake of my approach. In the courses that I passed, did not work with multidimensional structures. Did I choose the type of variable for storing data correctly - a dictionary? What is the right thing to do here?

    the structure of the data that needs to be obtained

    an example of data csv

      Person_id; Gene_name; Polfzm_name; Genotype; Expr1; Group  1086 ; at1; f11; t/c RS2036914; take a rally; take;  3    1086 ; at1; f11; s/t rs2289252; take away;  3    1086 ; at1; itga2; c/t rs1126643; ct; take away;  3    1086 ; at1; itgb3; t/c; t/c RS5918; take a rally;  3    1086 ; at1; vegf; c/t rs3025039; take a rally;  3    1085 ; at2; f11; t/c rs2036914; tt; take a rally;  3    1085 ; at2; f11; s/t RS2289252; take a rally;  3    1085 ; at2; itga2; c/t rs1126643; tt; take on frequent;  3    1085 ; at2; itgb3; t/c rs5918; tt; take a rally;  3    1085 ; at2; vegf; c/t; RS3025039; take a rally;  3    23 ; Foreign Ministry  6 ; ac; alu inds/del; ID; class = ""> 1    23 ; Foreign Ministry  6 ; f1; thr312ala; pregnanthrm;  1    23 ; Foreign Ministry  6 ; f11; t/c RS2036914; tc; pregnanturm;  1    23 ; Foreign Ministry  6 ; f11; s/t rs2289252; ct; pregnant gram;  1    23 ; Foreign Ministry  6 ; f13; val34leu; valleu; pregnant gram;  1    23 ; the Ministry of Foreign Affairs  6 ; f2; g20210a; gg; pregnant gram;  1    23 ; Foreign Ministry  6 ; f5; arg506gln; gg; pregnant core;  1    23 ; FMI  6 ; itga2; c/t RS1126643; CC; PCP;  1    23 ; Foreign Ministry  6 ; itgb3; t/c RS5918; tc; class = ""> 1    23 ; Foreign Ministry  6 ; vegf; g-634c; gg; taken;  1  

    data - flat data sample from a relational database. T.K. There were connections, and the data was selected from several tables, many values ​​from the line to the line are repeated. For example, the first 5 lines of data (not taking into account the hat) - belong to one person (person_id), one group (Group), but have different genes (Gene_name), etc.

    , according to data, it is planned to make multiple comparisons, search for combinations, etc. - the order of ~ 4 million passes, so you need such a structure as not to run along all lines of CSV so many times

  • аватар форума question@mail.ru · 0000-00-00 00:00:00 · асинхронность, python, помощь, пример, requests
    Asynchronous HTTP calls Grequets

    always used the Request library. But how I can’t change my memory there, you can send a request to only 1 http url and only then to another, in tu. Grequests as it is written can be sent simultaneously at least 10 url asynchronism. But I don’t know how to do it, I have already tried it. The file has approximately 150 URLs. Code:

       import  makerssimplese =  'http://shost-craft.su'    with   open  ( "" C: \\ Cruelnetwork \\ Cruel.need \\ wolfs.txt "" )  as  werewolves:  array = [row.strip ()+simplesite  for  row  in  werewolves] params = { '' a 'a'  '' b ',  'c' :  'd' } rs = (Grequests.post (u, data = params)  for  u  in  in  map  (RS)   print  (RS)     

    I waited for about a minute, I understand it for a very long time. And I don’t know how to solve this problem. Or is it just the same fast? At the end, it was displayed on the screen: & lt; Generator Object & Lt; Genexpr & GT; AT 0x0000029AD8D29A98 & GT; I want a request to 10 URL addresses immediately, not in tu, but immediately for 10 addresses. Or can not be implemented using this library?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python
    Automatic filling of the form in Django Template

    Good afteoon.

    there is a form of user profile. When displaying on the screen, it must be filled with the data of the current user. How can this be done?

       class   profile  (models.model):  User = models.onetoonefield (user)  img = models.imagefield (upload_to =  true , Verbose_name =  '"avatar' )  Phone = Models.integerfield (max_length =  10 , verbose_name = )   class   propiLEFORM  (forms.FORM):  first_name = forms.charfield (Label =  u'ym ', max_length =  30 , required =  true )  last_name = forms.charfield (label =  u'familia ', max_length =  30 , required =  true )  password = forms.charfield (label =  u'parol ', widget = forms.passwordinput, min_length =  4 , recuired =  true )  email = Forms.mailfield (Label =  u'e-mail ', required =  true )  Phone = Forms.Charfield (Label =  U'"" " Phone ', max_LENGTH =  10 , required =  true )  Img = forms.imagefield (label =  u'vash authar or autar Logo ', required =  false )  @render_to (  'prote.html'  )    def   edit_profile  ( request ): ): ) Form = loginform ()  {{form_profile.as_p}}     

    I want to fill the form automatically (with my hands in the template not to paint anything). Thank you!

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python
    Replacing values ​​in a particular Dataframe column by dictionary

    It is necessary to replace the values ​​in a particular Dataframe column by the dictionary, if you are not found, you need to remove the entire line from Dataframe.

    I was able to complete the task as:

      DICT1 = { 'car' :  'c' ,  '' motorcycle" :  'mt' ,  'truck' :  ''}} df = pd.dataframe ({span class> '' 'product ":  'Truck Motorcycle Car Tire Wheel Truck' . Split (),   'price' :  10000 ,  5000 ,  23000 ,  15000 ,  500 ,  300 ,  8000 ]}) df [ 'product_new' ] = df [ '' 'product' ].  map  (dict1) df.dropna (inplace =  true ) df.drop ( '' 'product' , axis =  1 , inplace =  true ) df_new = df.reindex (columns = [ '' 'product_new' ,  'price' ])     

    is it possible to replace values ​​immediately in the product column without creating an intermediate column and getting rid of the lines by which the key in the dictionary was not found?

    replace , but somehow it did not work out.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · словарь, python, вопрос, пример
    Composite python dictionary with several values ​​from other dictionaries in an identical key

    I will immediately make a reservation & ndash; I am not a programmer, but I study Python for my own specific purposes (processing data obtained from the network), so if my question seems naive and simple & ndash; I ask you not to blame.

    So, there are three different dictionaries with identical keys. Values ​​& ndash; Different, but can coincide both within one dictionary and in different dictionaries. For example (I did the values ​​in the form of a list, because I understand that it will not work out to add values ​​in a different way):

      Dict_1 = { `` `SPAN>: [ 2 ],   'b' : [ 8 ],   'c' : [ 6 ],   'd' : [ 2 ]} dict_2 = { '' a 'a'  2 ],   'b' : [ 7 ],   'c' : [ 7 ],   'd' : [ 3 ]} dict_3 = { 'a' a ': [ 3 ],  ' b ':  6 ],   'c' : [ 8 ],   'd' : [ 3 ]}     

    Task: to get a new dictionary (either from scratch or based on one of these & ndash; absolutely not important) in which each key will receive values ​​from all three dictionaries:

      DICT_ALL = { 'a' : [ 2 ,  2 ,  3 ],   'b' : [ 8 ,  7 ,  6 ],   'c' : [ 6 ,  7 ,  8 ],   'd' : [ 2 ,  3 ,  3 ]}   
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, python
    How to remove gaps in the list

    I have a list

      Word = [ '' , ,  '' ]     

    how to remove empty lines from the list?

    I do on a pyton

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · вопрос
    Russian names for the fields of the database in the admin

    The question is coy simple, but something didn’t figure out something ... How to do that Russian names for the database fields were displayed in the admin panel? What needs to be prescribed in Models.py?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, numpy, pandas
    How to remove lines according to different conditions?

    there is a data frame and I need to delete lines from it in which the value of the column a is more than 50. This operation is successfully performed by the code:

      Import  pandas  as  pd  import  numpy  as  nprondf = PD.Dataframe ([ 256 ,  4 ,  24 ,  51 ], [ 24 ,,  25 ,  34 ,  200 ], [ 300 ,  12 ,  45 ,  11 ],  [ 34 ,  19 ,  2 ,  34 ], [ 75 ,  76 ,  19 ,  11 ], [ 42 ,  89 ,  29 ,  101 ], [ 54 ,  104 ,  11 ,  12 ]]) df.reneame ({ 0 :  'a' a 'a' a `` ",  1 :  'b' ,  2 :  'c' ,  3 :  'd' d '}, Axis =  1 , inplace =  true ) df_without_noise = df.drop (df [ 'a' ] & gt;  250 ) [ 0 ])  

    and it tus out DATA-HIGHLIGHTED = ""> A B C D 1 24 25 34 200 3 34 19 2 34 4 75 76 19 11 5 42 89 29 101 6 54 104 11 12

    Then you need to remove the lines in which the column in is more than 50. I repeat the operation similar to the first removal of the lines:

      df_without_noise = df_without_noise.drop (np.where (df_without_noise [] & gt;  50 ) [ 0 ])     

    but displays the error:

    keyeroror: '[2] not found in Axis'

    In this case, the column in contains values ​​of more than 50.

    how to remove lines with them? DATA-HIGHLIGHTED = ""> A B C D 1 24 25 34 200 3 34 19 2 34

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · lambda, список, словарь, python
    Delete a dictionary from the list of dictionaries

    I have a list with dictionaries. Where the person’s name is indicated, where and where it goes. But one dictionary has no meaning "from" from ". How to delete this dictionary from the list?

      Tour = [ {  "name" ": ,  :  "" "Moscow" ",  :  "" Kazan ""  },  {  "name" ": ,   "" from ":  "Moscow" ",  :  "" Kazan " },  { " "NAME" " "" Sergey "" ,   "to" ":  } ]     

    I tried to do it in several ways, but nothing It tus out

      #method 1  new_tour = [i  for  i  in  tour  if  (I [ 'from "] ==  none )]  #method 2  new_tour =  line  ( filter  ( lambda  i: I [ 'compers] ]! = = "  none , tour))  #method 3    for  i  in   range  ( len  (Tour)):   if  tour [i] [ 'from "] ==  none :   del  tour [i]   break    
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ошибка, python3, pip, debug
    Pyaudio is not installed

    The PyAudio library is not installed. I tried pip install PyAudio. First, he told me to download Microsoft visual c++. Downloaded and installed it. Now this error

    C:\Users\sulay\Downloads\Python\Artificial intelligence>pip install PyAudioCollecting PyAudio  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gzBuilding wheels for collected packages: PyAudio  Running setup.s: PyAudio  Running setup.py bdist_wheel for PyAudio ... error  Complete output from command c:\users\sulay\appdata\local\programs\python\python37-32\python.exe -u -c ""import setuptools, tokenize;__file__='C:\\Users\\sulay\\AppData\\Local\\Temp\\pip-install-xwgazswg\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))""/span> bdist_wheel -d C:\Users\sulay\AppData\Local\Temp\pip-wheel-m8k2zafm --python-tag cp37:  running bdist_wheel  running build  running build_py  creating build  creating build\lib.win32-3.7  copying src\pyaudio.py -> build\lib.win32-3.7  running build_ext  building '_portaudio' extension  creating build\temp.win32-3.7  creating build\temp.win32-3.7\Release  creating build\temp.win32-3.7\Release\src  C:\Program Files (x86)lease\src  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\sulay\appdata\local\programs\python\python37-32\include -Ic:\users\sulay\appdata\local\programs\python\python37-32\include ""-IC:\Program Files (x86)am Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\inMFC\include"" ""-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.24.16.27023\include"" ""-IC:\Program Files (x86)\Windows Kits\10\includinclude\10.0.17763.0\ucrt"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared""/span> ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um""0\um"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\763.0\winrt"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt""/Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.7\Release\src/_portaudiomodule.obj _portaudiomodule.c src/_portaudiomodule.c(29): fatal error C1083: no current version; It contains: portaudio.h: No such file or directory, error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe ' failed with exit status 2 ---------------------------------------- Failed building wheel for PyAudio Running setup.py clean for PyAudioFailed to build PyAudioInstalling collected packages: PyAudio  Running setup.py install for PyAudio ... error    Complete output from command c:\users\sulay\appdata\local\programs\python\python37-32\python.exe -u -c ""import setuptools, tokenize;__file__='C:\\Users\\sulay\\AppData\\Local\\Temp\\pip-install-xwgazswg\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"" install --record C:\Users\sulay\AppData\Local\Local\Temp\pip-record-k_mb8hmx\install-record.txt --single-version-exteally-managed --compile:    running install    running build    running build_py    creating build    creating build\lib.win32-3.7    copying src\pyaudio.py -> build\lib.win32-3.7    running build_ext    building '_portaudio' extension    creating build\temp.win32-3.7    creating build\temp.win32-3.7\Release    creating build\temp.win32-3.7\Release\src    C:\Program Files (x86)ase\src    C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\sulay\appdata\local\programs\python\python37-32\include -Ic:\users\sulay\appdata\local\programs\python\python37-32\include ""-IC:\Program Files (x86)am Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\inMFC\include"" ""-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.24.16.27023\include"" ""-IC:\Program Files (x86)\Windows Kits\10\includinclude\10.0.17763.0\ucrt"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared""/span> ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um""0\um"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\763.0\winrt"" ""-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt""/Tcsrc/_portaudiomodule.c /Fobuild\temp.win32-3.7\Release\src/_portaudiomodule.obj _portaudiomodule.c src/_portaudiomodule.c(29): fatal error C1083: no current version; It contains: portaudio.h: No such file or directory, error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\cl.exe ' failed with exit status 2 ----------------------------------------Command ""c:\users\sulay\appdata\local\programs\python\python37-32\python.exe -u -c ""import setuptools, tokenize;__file__='C:\\Users\\sulay\\AppData\\Local\\Temp\\pip-install-xwgazswg\\PyAudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec'\n');f.close();exec(compile(code, __file__, 'exec'))span>))"" install --record C:\Users\sulay\AppData\Local\Temp\pip-record-k_mb8hmx\install-record.txt --single-version-exteally-managed --compile"" failed with error code 1ode 1 in span> C:\Users\sulay\AppData\Local\Temp\pip-insta
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · пример, ии
    Telegram Bot delete bot

    I use Pytelegrambotapi how to delete a bot in a chat? For example: the bot gives the user several buttons, and when you press on one of them, the field with buttons is removed.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ии
    Selection of part of the password by passing the mask and Sha-256

    I have a piece of password *ELP ** (instead of stars there should be the characters that need to be selected), but I know from it sha256 hash:

        IMPORT  hashlibmas = [, , , " "d" ,  "" e "" , , " g "" ,  "h" ",  "" i "" , , " k "" ,  "" l "" ,  "" m "" , , " o "" ,  "p" ",  "q" ", ,  "s" ", " "t" ",  "" u "" , , " w "" ,  "x" ",  "y" ", ,  "" a "" , ,  "" C ", , ,  "f" ",  "g" ", , ,  "j" ",  "" k "" , , " m "" ,  "" n "" ,  "o" ", , ,  "r" ",  "s" ", ,  "u" ", " "v" ",  "" w "" , , ,  "z" ",  "" 1 "" , , , " "" "4" ",  "" 5 "" , , " "7" ", " "8" ",  "" 9 "" ,  "" 0 "" ] a =  b'hello ' shlib.sha256 (a) .hexdigest ()   Print  (Sha)   
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, ии
    Using the variable in the regular expression python

    Salute! Please help to solve it would seem trivial, but for lack of experience in programming, an absolutely unusual task for me :)

      mt = re.findall ( r '\'" "variable" "\ s \ '' )     

    instead of" variable "" should be a variable, which will be consumed by different lines, and I do not know how to present it correctly.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python
    Task: converting a line from a camel register into a snake

    You need to convert a line from a camel register to a snake, add the ability to change the separator. I solved the problem, but I would like to know how to solve it more correctly.

       def   Camel_to_snake  (  str , sp =  '' ' ):  snake_register =  '' '   for  i  in   str :   if  i.isupper: : : : : : : : :  Snake_register += Sep +I.Lower ()   else :  synake_register += i  Print  (Snake_register.lstrip (SEP)) camel_register =  'thisiscamelcased'  camel_to_snake (Camel_Rregister,  '_' )   
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, pandas, matplotlib
    How to streamline the dates on the graph in an increase in the order?

    Est CSV File with a number of sick people over the past year, but it has an incorrect structure, i.e. At first there is today's date, then yesterday, etc.

    how to build the correct schedule, so that from the past to the present, and not vice versa?

       import  PANDAS  as  pd  import  matplotlib.pyplot  as  plandata = pd.read_csv ( 'Data.txt' ) plt.plot (Data [ '"call" ]) plt.show ()     

    tried: data = Data [::-1]

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · итератор, python, пример
    Why do you need Commit, Connection, Cursor and Close?

    Basic example

      import psycopg2 # connect to an existabase  conn = conn = psycopg2.connect ( "dbname = test user = postgres" ")  # open a cursor to performation  cupir = Conn.cursor ()  # execute a commander: this creates a new one  cur.execute ()  # pass data to fill a query PlaceHolders and Let PSYCOPG PERFORM   # the Correct Conversion (no more sql injection!)  cur.execute ( "" Insert Into Testa (Num, Data) Values ​​( %S, %S) ", r ... (100,  "" abc'def "" ))  # query the database and obtain data as pythjects  cur.execute ( "" select * from test; "" ) cur.fetchone ()  # make the changes to the database passistent  conn.commit ()  # Close Communication with the Database  cur.close () conn.close ()     

    for which needs is used cur.close () , confn.commit () , conn.close ? What are their differences?

    , for example conn.commit () , as indicated in the example, applies changes. But it seems more logical that the cursor will be responsible for this, because it is he who is an iterator according to the data.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, python, пример
    Proper transfer of the line to Python

    Tell me, there is a list with phrases, but they are long and pep8 swifts over the length of the line.

    I transfer the part of the phrase the symbol \ , but then he counts all the gaps.

    Example:

      List_of_Words = [ "" "The Weather is good." "" ,   "" Hot Dog is the Best Food, \  It Woold Be a Sure Sign that It was Still Yummy. "" ,   "" "The Girls are beautiful." ",  ]   print  (*line_of_words)  

    the conclusion:

      The Weather  is  good. HOT DOG  is  the best food, it will be a sure sign that it was Still Yummy. The Girls are Beautiful. Any text, it doesn’t matter, but after Baxles is a huge rasture between words. How to fix this?     

    How to avoid this nonsense?

    p.s. DATA-HIGHLIGHTED = ""> LIST_OF_WORDS = [, " "" Hot Dog is the Best Food, \ it Wuld Be a A Sure Sign that it was Still yummy. "" , "" The Girls are beautiful. "" , "" Text is a huge \ ravas. between words. How to fix this? "" ] print (*list_of_words)

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python
    Cut all the emoticons from the line

    Suppose we have a line:

       "" ????????? & zwj; ?? ?? & zwj; ?? & zwj; ❤ & zwj; ? & zwj; ?????✋??? What a wonderful day! ""      

    as this from this one from this Remove all the emoticons and get only a pure text at the output:

        

    In this case, the emoticons can be completely different not necessarily those in the line.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, строка, python
    Line conversion to sorting in lexicographic order

    How to convert a string consisting of words separated by spaces, and sort the resulting list in a lexicographic order?

    is given a line from words separated by spaces:

      S =  'ABC a BCD BC ABC BC BCD BCD ABC'      

    We convert it to the "Space" "" Space "":

      A = S.Split ( '' )     

    we get:

      [ 'Abc' ,  '' a ', ' bcd ', ' bc ',  'Abc' ,  'bc' ,  'bcd' ,  '' bcd ',  'ABC' ]     

    class = ""> print (a)

    we will not get anything if:

      b = a.sort ()   Print  (a)     

    We get the sorted list

      [ 'ABC' ,  'Abc' ,  'bc' ,  '' "> '' bcd ', '` `` span>,  'ABC' ,  'bc' ,  'bcd' ,  '' "> ''"> '' "]   

    why? Is it possible to somehow combine sort () and split () in one line?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · вопрос
    Record to a specific line line on Python

    There was a need to write data in a certain line in a large file for a couple of gigs. More specifically, now you need to read the line, then process it, and then delete it from the text file.

    I found a solution consisting in to consider the entire file to the variable, then make changes to the variable and write everything out of the new one, but for a large amount of data, this is obviously not the best option.

    can it be more simpler? If not, then the question itself is, how to write data in a specific line without rewriting the entire file?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · вопрос
    How to get ID user Aiogram

    You need to get the user ID who uses the bot. How can this be done in Aiogram?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, django, проект
    CSS connection to Django template

    Good day to everyone! I have a “proj” project on Django, the “BLOG” application has been created in it. In the file "" ..../Proj/Blog/Templates/Page.tpl "you need to connect the" Style.css "file" which lies in the same folder. How to register the path to call

      Render_to_Response ( 'page.tpl' . CONTEXT)     

    The generated page found CSS file?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · работа
    How does Qscrollarea work?

    Please explain how you can work with qscrollarea . He did in the designer, but does not work. I did not find normal solutions on the Inteet

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · ооп, python, пример
    The meaning of this in C ++ / Self in Python

    What is the essence of Self in the OOP of the Python and this in C ++ (better in examples)?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python
    Cyrillic in Python

    Is there an analogue in Python for string.Askii_letters , only for the Cyrillic alphabet?

       & gt; & gt; & gt;   Import  string  & gt; & gt; & gt;  string.Askii_letters  '' 'AbcDefhijklmnopqrstuvxyzabclmnopqrstuvwxyz'    & gt; & gt; & gt;    
    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, вопрос, работа
    How to make friends Python and C ++ | Python to Bin/EXE

    Hello again.

    is the task of rewriting the existing classes/structures of data in Python to C. I have little idea how to work, but the task is set, it is necessary to study. Please tell me how this should look? It is preferably real experience because links are not always saved. And most importantly, how much will this accelerate the implementation of the software code?

    the alteative to this type of senimal of its bosses, I see the compilation of Python in the executable application (Linux-Binary, Windows-Exe). What do you think on this issue?

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · python, совет, python3, requests, работа
    python download VK files

    connected the VK API. It is necessary to send files to the server as this is described on this page - P.S. Downloading files to the user wall

       import  vk  from  time  Import  SleEP  Import  sys  import  urollib.request  import  urllib.parse  Import  base64  import  recrunvkapi = vk.api (access_token =  'token' , app_id =  'd' ) sleep ( 0.5 ) data = vkapi.photos.getwalluploadserver (user_id = ) data_user_id = DATA [ 'user_id' ] data_albus_id = Data [ 'album_id' ] data_upload_url = data [ 'upload_url "]  #with open (" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Rb" ") as Image_file:   #filed = base64.b64encode (imge_file.read ())   #files = {'' 1.jpg ': Open ('1.jpg', 'rb')}   #r = rhequests.post (data_upload_url, files = files)   #r.status_code == Requests.codes.ok   #print (r)   #html = r.read (). Decode ("UTF-8" ")   #Datap = '1.jpg'  datap =  "" Photo = ""  + Datap #. Encode ("asci" ")  response = urllib.request.urlopen (Data_upload_url, Datap) html = Response.read (). Decode ( "" utf-8 "" )     

    the grate is marked that I tried but did not work or did not fit.

    it seems like the option with

      '1.jpg' :  '' 1.jpg ', ' b ')} r = REQUESS.POST (DATA_UPLOAD_URL, Files = Files) r.status_code == Requests.codes.ok  print  (r)  #html = " R.Read (). Decode ("UTF-8" ")      

    However, in this case, I can’t understand whether the request has been worked out properly. class = ""> {: 622624 , "" Photo "" : "" "" ", " hash "" : "" 8112ae8847b27fb1cdf678d3d168e6ae "" }

    that is, the download of the image is a failure. Python3. Share your experience, advice, remark. If something in the code is incomprehensible - write; I will answer.

    аватар форума question@mail.ru · 0000-00-00 00:00:00 · список, помощь, пример, ии
    Load the number of numbers

    from the user, using the input function, I get a six -digit number.

    After that, you need to divide it into 6 independent numbers, for example, the list.

    how can this be achieved? 1, 2, 3, 4, 5, 6

    Interesting