Questions tagged as 'python'

2
answers

How to read hyphen-separated numbers in a text file?

Let's say I have a text file where its configuration is: 1-2-3-4-5-6-7-8-9-10-11-12-13-14-15-16-17-18-19-20...-999 How do I read the file and save each number of the one that is separated by - ?     
asked by 23.11.2017 / 18:31
0
answers

Django Channels Routing not working

I wanted people to access my URL as usual before (to install channels) localhost/home/minha-slug and to detect socket messages within that route. I want to create Groups not to be sending messages to all of the site, but who is on the pag...
asked by 27.11.2017 / 21:38
0
answers

How to send an image correctly via Socket in Python

I'm trying to send an image from the 'dir' directory to another client in my network. Sockets are working properly, the image arrives at the destination and is saved, but when I try to open it I get: "This is not a valid bitmap file." #Cód...
asked by 10.12.2017 / 01:26
0
answers

Selenium works with Firefox, but not with Chrome

I was normally using Firefox in Selenium with Python, but wanted to do some testing using Google Chrome, so I made the following change: self.driver = webdriver.Firefox() To self.driver = webdriver.Chrome() It opens Google Chrome but s...
asked by 16.11.2017 / 12:50
1
answer

How to Separate Data in a Dictionary from a .txt (Python)

I have a text file (attachment.txt), which I have to store in a dictionary, with Name as key and phone, value. the file has the following information: --- nome telefone --- Ailton-1197765445 Josefa-2178655434 I used the following code: re...
asked by 12.11.2017 / 03:39
0
answers

How can I update the text position when I change the button position?

I have a class button that is a sprite and has a text attribute that is also a sprite. I wanted to know how to change the position of the text when I change the position of the button rect? import pygame class Botao(pygame.sprite.Sprite):...
asked by 12.11.2017 / 13:02
1
answer

How to Create a Communication Between Two Clients via Server Using Socket

import socket from threading import Thread def client(h, p): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4,tipo de socket s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) while True: try: s...
asked by 13.11.2017 / 15:42
1
answer

The code is right, but could anyone tell me how True and False works in detail in this question (step-by-step)?

"Make a program that, when you populate a list with 8 integers, store it in a growing fashion. Display the resulting list each time a value is stored" lista = [] for x in range(8): n = int(input("Digite um número inteiro: ")) inseriu...
asked by 10.11.2017 / 01:15
1
answer

Binary search in python giving wrong answer in Moj

def busca(num, a, primeiro, ultimo): meio = int((primeiro + ultimo) / 2) if num == a[meio]: return meio elif num < a[meio]: return busca(num, a, primeiro, meio) else: return busca(num, a, meio+1, ultimo)...
asked by 09.11.2017 / 01:49
2
answers

How to check if the txt file has a space in the last line

I have a script here that looks for all the .txt files in a folder and then joins them into one file. The problem is that some files have a "\ n" in the last line, causing the next line not to be below the previous one, causing errors when I...
asked by 09.11.2017 / 14:09