Questions tagged as 'python'

1
answer

Using recursion to count the number of times a number appears in a list

I have created a recursive algorithm to count the number of times a certain n appears in a ls list. It seems to work if the ls list is quite small (between 10 and 100), but if it is large, type 1000, it does not seem to work...
asked by 01.01.2016 / 01:27
1
answer

How to do select count (*) with Python and mysql.connector

The library I'm using is this . This is the code: cur.execute("""SELECT COUNT(*) as total FROM tabela as t WHERE ... """, (v1, v2)) for (total) in cur: if total > 0: print('Existe') The problem is that there is never an...
asked by 07.01.2016 / 01:25
2
answers

How to import Python libraries that are in another hierarchy?

I have the following directory structure src\ conectores\ mysql.py bibliotecas auxiliares teste\ chamarMysql.py In the above structure how can I inside the test file \ callMysql.py, make a call to a class that...
asked by 29.08.2016 / 21:16
2
answers

Doubt with Python + django

I'm starting with Python and Django, following a tutorial I found: link When I run the django-admin command with startproject, it does not generate that folder structure it shows in the tutorial, it just creates a file that opens dir...
asked by 17.06.2016 / 18:47
1
answer

Editing python files

I have the intention of inserting into the files .py the following section: -*- encoding: utf-8 -*- It needs to be specific online, and in large amount of files. Is there any unix / linux tool that can perform this task?     
asked by 10.06.2015 / 21:16
1
answer

Send .txt file from one pc to another using http service

I need to send a file from one PC to another over the network, only using link requests, so I do not have to download at the socket level, which gives a job. Is anyone able to clear me with some API or code sample? PS: I'm not lazy, unt...
asked by 31.01.2016 / 21:59
1
answer

Problem comparing strings and string being broken in two python rows

I was creating a game that scrambles words, and the user has 6 attempts to guess what the word is. I'll put the code here: import random def main(): while True: input('Presisone enter para sortear uma nova palavra.') palav...
asked by 04.05.2015 / 14:50
1
answer

Calling another terminal with python

I'm doing a project here and need to open another terminal window, which runs the command ls . I have tried with subprocess but it gave error: Traceback (most recent call last): File "tests.py", line 8, in <module>...
asked by 21.01.2015 / 15:53
1
answer

Multiple pipelines to handle different spiders in Scrapy

How to handle pipelines.py when we have different spiders? Example: I have a Spider that works by getting blog posts from one blog and another by saving images of jpeg banners found on each page. Both spiders work, but I use the same pipeline...
asked by 09.01.2015 / 20:54
1
answer

How to call a Python script in a C ++ code in Qt creator?

How do I call a Python script in a C ++ code in Qt creator?     
asked by 11.02.2015 / 18:18