Posts by Benedito • 541 points
24 posts
-
0
votes1
answer130
viewsQ: Infinite wait per server response using python sockets
I am trying to send a message to a server API in order to get a response. I am using the following code: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address =…
-
0
votes1
answer213
viewsQ: How to make the elements of a tuple to be the arguments of a python function?
I will first remove the problem and then explain what I am trying to do. If you know how to answer the short problem, you don’t need to see the rest. Is there a way to pass the elements of a tuple…
-
2
votes2
answers1898
viewsQ: Regex to pick up text between <> in python?
I would like to extract the text contained between <> of a string. At first, I built the following expression: import re m=re.search(r'<(.*)>','abevbv envvrhwkv <eiwbv> ebvi…
-
2
votes1
answer123
viewsQ: How to extract the icon from a . exe file using python?
I simply came to need to have an image file . ico extracted from a file . exe and do not even know how to start. How can I do this?
-
1
votes1
answer78
viewsQ: Problem in understanding this structure in a python string
I was studying file compression when I came across the following script: import sys import os.path import bz2 import zlib import base64…
-
1
votes0
answers667
viewsQ: Problem making python script request administrator permission
Use Python 3.5 on Windows 8 and a simple script presented problem: I want to copy a file from my desktop to C: Windows folder. First I tried that: from shutil import copy…
-
1
votes1
answer753
viewsQ: How to create a pause method and one that resumes a Thread?
The following script shows the x variable every 3 seconds, while the xx class, which is running on a thread, increases the x value every second. I would like when the value of x reaches 13, the…
-
4
votes1
answer387
viewsQ: How to get a string with the name of the window that is focused in python?
Some time ago I started using pyHook to manipulate events. However, the original version has errors, so I switched it to an alternative version that corrected the errors of the original version.…
-
2
votes2
answers2519
viewsQ: How to compress a folder with everything inside using python zipfile?
I am wanting to compress a file and a folder that has multiple files inside in a single file. zip using Python. The script is next p: from zipfile import ZipFile,ZIP_DEFLATED def zipar(lista): with…
-
2
votes2
answers2038
viewsQ: How do one class that is inside another inherit an instantiated variable from the last one in python?
See the following python script: class a: def __init__(self,n): self.n=n class b: def __init__(self): ## o que botar aqui para receber a variável self.n ## def show(self): return self.n…
-
3
votes2
answers6889
viewsA: how to find and change a specific python line?
To replace a particular row of a file, you can use this function: def alterar_linha(path,index_linha,nova_linha): with open(path,'r') as f: texto=f.readlines() with open(path,'w') as f: for i in…
-
1
votes1
answer466
viewsA: Visual Studio utf-8 error
Try this: #coding: UTF-8 print('olá') Depending on the Python version, the encoding used should be specified if you want to use special characters. If it doesn’t work, try this too: #coding: latin-1…
-
0
votes1
answer217
viewsA: Error pressing Alt+Tab using pyHook
This is an error in the pyHook script itself. A solution to this problem is to install a modified pyHook found here. To install, you need to download Swig here. Installation: Open the cmd Give up…
-
1
votes1
answer1560
viewsQ: How to make a python script run two processes simultaneously?
A little while ago I learned to capture videos via webcam using Python with the Opencv library. After that, I had the idea of making a script that automatically starts and ends the recording of a…
-
1
votes1
answer1543
viewsA: How to send email with body and attached using smtplib and email in python?
After further searching, I discovered that the Mimetext object, in addition to storing text attachments, can also store the email body. The following function returns a mime object by storing a…
-
3
votes1
answer3590
viewsQ: How do I send a file as an attachment by email without automatically renaming it?
I am beginner in sending emails via script and am facing a problem. I use Python 3.5. When sending attachments with the following script, they lose the extension and are renamed: def…
-
4
votes1
answer1543
viewsQ: How to send email with body and attached using smtplib and email in python?
When I send a simple Python email using only the smtplib library, I can write in the body of the email through the "message" argument of the following script function: def…
-
4
votes1
answer1728
viewsQ: How to save a video captured by webcam without showing it using Opencv in python?
I’m starting to learn Computer Vision. I’m using the Opencv module for Python 3. Reading tutorials, discover the following script: import cv2 cap = cv2.VideoCapture(0) fourcc =…
-
3
votes2
answers2422
viewsQ: How to get a list of processes running windows in python?
I would like to know how to get the processes running from windows and store them in a list in python. from os import system system('tasklist') I know that the code above shows the processes, but I…
-
1
votes1
answer529
viewsQ: Access Denied when entering value in windows registry by Python
In an attempt to create a function that inserted a value in a windows registry key, I came across an error. I use Windows 8 and Python 3.5. The function is as follows: def inserir1(nome,path):…
-
0
votes1
answer779
views -
1
votes1
answer247
viewsQ: Import error when sending simple email with python
I am learning to send email in python and I am facing several problems. One of them is already in the import of the smtplib module. My code is this: from smtplib import SMTP…
-
1
votes1
answer217
viewsQ: Error pressing Alt+Tab using pyHook
I am working on a python script that captures keystrokes typed by the user. For this, I used the pyHook module. However, using the program, I realized that every time the user presses Alt+Tab, an…
-
3
votes1
answer356
viewsQ: How can I change file attributes in windows with python?
I am trying to keep a file . txt hidden. How can I do this using python command line?