Most voted "python-2.7" questions
In the 2.x series of the Python programming language, version 2.7 is last and the latest. Use this tag only if the problem is specific to this version. Also use the [python] tag in your question.
Learn more…477 questions
Sort by count of
-
1
votes1
answer38
viewstranformative
def eR(k,x): if k<=1: return 1 else: return (x**k)/eR(k-1,x)*k x=int(input("Insira o X:")) k=int(input("Insira o número de…
-
1
votes0
answers327
viewsHow to send an image correctly via Socket in Python
I am trying to send a picture of the dir directory to another client of my network. The sockets are working properly, the image arrives at the destination and is saved, but when I try to open it I…
-
1
votes1
answer3482
viewsSend POST form with python
I am developing an API in my work, and I need to develop something in python2 that sends a form to the server through the POST, I saw some questions here on the forum and I could not find anything…
-
1
votes2
answers95
viewsHTML alignment using Python
I need to line up a html code, in some parts it comes totally "messy", example: <li><a href="dsadas">dsadaads</a></li><li><a…
-
1
votes2
answers778
viewsDoubt about the Slice function
To the answer back that one question that the Guilherme Nascimento P. did, opened up a doubt on the use of the function slice, until the moment I had no knowledge of it, and to find it in the…
-
1
votes1
answer1949
viewsProgram a Python function to always run on the last Friday of the month
The code below demonstrates an example of how to program, but is somewhat limited to minutes, hours and days. I need one that also includes the month and the specific day, which in my case is…
-
1
votes1
answer895
viewsConvert fraction of hour to hh:mm:ss
My hourly data set is stored in the time = [0 variable. , 0.08333333, 0.16666667, 0.25, 0.333333, 0.41666667, 0.5 , 0.58333333, 0.666667, 0.75, 0.83333333, 0.91666667, 1. , 08333333, 1.16666667] Can…
-
1
votes1
answer650
viewsHow to use the Keyboard library?
How do I use the Keyboard to perform an activity if a certain key is pressed? In my research, I couldn’t find any example in this mold: import keyboard b = 0 if keyboard.press('b'): #sei que o certo…
-
1
votes2
answers350
viewsFonts for standard Python functions
Is there any way I can figure out the algorithm behind functions like split() and in in Python, because in my faculty there are some forbidden functions.
-
1
votes1
answer61
viewsHow to make a Sorted by a specific csv column?
I have a file. csv and need to make a Sorted by a specific column ('salary' column) and list by the column 'name' the top 10 salaries without using PANDAS. Can you help me? Thanks in advance.…
-
1
votes1
answer178
viewsHow to indent a yaml file using regular expression?
PROD ="IND" LOCATION ="NY" LOLO ="abc" yaml_content = """ MAIN : PROD : {} LOCATION : {} EXTRA : LOLO : {} """.format(PROD, LOCATION, LOLO) yaml_content = re.sub("\n\s", "\n", yaml_content.strip())…
-
1
votes0
answers17
viewsProblem sending strings with special characters in xmlrpc
I’ve been getting the bug for some time: xmlrpclib.Fault: <Fault -32700: 'parse error. not well formed'> When trying to send the following string via xmlrpc, In the python 2.7 base =…
-
1
votes1
answer1047
viewsZerodivisionerror: integer Division or modulo by zero
The code: janela=[] for i in range(100): if(len(leitura)%i == 0): janela.append(i) The mistake I get is this: Zerodivisionerror: integer Division or modulo by zero…
-
1
votes1
answer177
viewsDraw picture centered vertical line
I am working with Python image processing using the PIL and Matplotlib library and I am not succeeding in the following purpose: I have the image below. I would like to draw on it a vertical and…
-
1
votes2
answers361
viewsHow to create an array with value one?
Hello I would like to know if there is a way and which would be the most correct way to create a list (or an array) with the ones filled with the value 1 given the length of another list. Exactly…
-
1
votes1
answer155
viewsConvergencewarning in the Lasso CV method - What can I do to solve the problem?
Could someone help me with this mistake? Convergencewarning: Objective Did not converge. You Might want to Increase the number of iterations. Duality gap: 3.5998713265016704, tolerance:…
-
1
votes0
answers336
viewsSend file via network with Python
Server #!/usr/bin/env python #-*-coding:utf-8;-*- import socket import os host = "127.0.0.1" port = 8080 addr = (host, port) skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM) skt.bind(addr)…
-
1
votes2
answers94
viewsHow to name the keys of a dictionary from a list (array)?
If I have a dictionary of this kind: dados = {"indice1": [1, 2, 3], "indice2": [4, 5, 6]} and want to name its keys: indice1, indice2 with the following array: names= ['nome1', 'nome2'] I can do…
-
1
votes1
answer428
viewsFind common values in two different dataframes
Editing the question: I have two Dataframes of different sizes, it’s them: df1 = pd.DataFrame({'bc': bc_1}, index=altura_1) df1.shape()=(73,1) >>> print df1 bc 1.175441 0.002884 1.115565…
python-2.7asked 6 years, 8 months ago Luana 59 -
1
votes2
answers25
viewsSearch for specific directories containing the entire path
Fala galera, I need help listing all directories that contain "_new", for example: /var/www/site_novo/teste already started the code to get the _new directories, it finds the same, but I need it to…
-
1
votes1
answer29
viewscolumn insertion via python series
I have a series collected from a column of dataframe. I need to create columns with each of this series. For example: serie = [] for s in serie: df.insert(loc=0,column=serie,value='int') columns: A…
-
1
votes1
answer90
viewsHow to read the contents of a "Generator Object" from the load_all method for yaml file?
I need to maintain a function that returns me a Generator Object from a yaml file. In another function I want to access the yaml file data. import ruamel.yaml def load(): yaml =…
-
1
votes1
answer22
viewsDjango+Python Weasyprint printing only one PDF page
Good morning guys, I have a code already developed, however, I have tried in all ways to break page and bring all pages to this document, someone can help me with this case? I’m using python 2.7 I…
-
1
votes1
answer652
viewsPython - Tabuada- For Exercise - Matrix
Good night! I’m trying to create a tabuada program using for and matrix, my code is like this at the moment: def crie_array(rows, columns, value): matriz = [] for i in range(linhas): linha = [] for…
-
1
votes0
answers115
viewsError reading binary python file
good night. I am trying to read the contents of a binary file in Python to assemble a dictionary, but when reaching the end of the file the program is "flying" and I am not able to capture the…
-
1
votes2
answers2495
viewsHow to make an array with attributes or objects of a class?
Good evening, I’m a beginner in python and I have a question about how to make an array of an object or class. My main program contains a function that cuts into text, delimiting blocks and so on.…
-
1
votes0
answers116
viewsPytho Kafka, Spark Streaming, Mongodb conection
Hello I am creating a job streaming, but I do not get error message and nor does recording in Mongo. I have tried several types of connection. On the command line, Producer and Consumer can produce…
-
1
votes1
answer1144
viewsImport: No module named 'telebot'
Hello! I am configuring the bot to send Zabbix alerts, I have installed Python and the necessary modules: sudo apt install python python-pip python-setuptools Then I installed the bot API to use in…
-
1
votes1
answer125
viewsFunction Returning Multiple Values in Python 2.7
It’s my first post on this forum, so I apologize in advance for any etiquette error. I’m trying to implement a function in Python 2.7 that returns me a random element from a list or a sublist of…
-
1
votes1
answer235
viewsHow to sort a python dictionary in descending order?
How can I order this dictionary so that it is in descending order: dict= {'1': array([44, 32, 56, 57, 43, 21, 36, 35, 39, 27, 23, 24, 25, 26, 31, 28, 29, 30, 20, 22, 18, 19, 8, 1, 33, 2, 3, 4, 0, 6,…
-
1
votes1
answer113
viewsHyperbolic cosine approach - Python
I have a little exercise to do: compare the result of the Cosh(x) approximation by Taylor series with the function you have in the Python library. The hyperbolic cosine Taylor series is: Cosh(x) = 1…
-
1
votes1
answer47
viewsHow to make a formatted print?
Hi. I’m sorry about the basic question, but I started dealing with python a week ago. I’m writing a program that records candidates' votes in a binary file. But, at the time of displaying I am not…
-
1
votes2
answers101
viewsDoubt about value extraction using Soup.findAll() in Python
Good afternoon to all. I am studying python and learning to extract data on websites and to start this learning I am creating a program that will extract the data from the lotofacil site of the…
-
0
votes3
answers913
viewsMultiple of 10 closest to a sum
def multiplo(x): somamulti= somaImpares(x) + somaPares(x) if somamulti/10==0: return somamulti/10 else: return In this function I did what happens is the following: the somamulti sum 2 values, in…
-
0
votes1
answer123
views"Interpret 8-bit bytestrings" error in Sqlalchemy
I’m starting with Sqlalchemy and came across this mistake: sqlalchemy.exc.ProgrammingError: (ProgrammingError) You must not use 8-bit bytes trings unless you use a text_factory that can interpret…
-
0
votes1
answer43
viewsFormat characters do not need to be specified?
Format characters have to be specified? for example: x = "Get rekt m8" print "Eu disse: %r." % x So why didn’t I need to specify this and it worked anyway? hilarious = False joke_evaluation = "Isn't…
-
0
votes1
answer3199
viewsInstall Spyder in python
How do I install Spyder in python 2.7 ? i already have Pip installed in python scripts and easy_install.. with the help of a friend but I don’t know how to install Spyder
python-2.7asked 10 years, 1 month ago CSAnimor 731 -
0
votes1
answer70
viewsFor x in range(y) does not return right
I have a problem with a def x() in python. the problem is "inside" it. Even if I put it right, it returns Isis, no matter. I’ve tried everything but I can’t figure out why he doesn’t return right.…
-
0
votes3
answers2326
viewsHow to install the scipy library in python?
I tried to install using Winpython program, but while importing the library an error occurred: ">>> from scipy.optimize import curve_fit Traceback (Most recent call last): File "", line 1,…
-
0
votes1
answer241
viewsTwisted Critical unhandled error in scrapy tutorial
I’m new in programming and I’m trying to perform the scrapy tutorial http://doc.scrapy.org/en/latest/intro/tutorial.html Use python 2.7 and windows 7. When I run cmd the command "scrapy Crawl dmoz"…
-
0
votes1
answer57
viewsHow to add new python encodings?
I’m trying to install the pybraces but I can’t. How do I install it ? I’m using python 2.7 and windows 10
-
0
votes1
answer3982
viewsError: "in module named xxxx"
I have Python installed on my Pcs (Windows 7 and 8) but I can’t run any script that contains import. Error message always appears: import error: no module named xxxx.…
-
0
votes1
answer108
viewsDisplay the value of a counter in a table
Long live, The goal is to simulate the iteration between the system and the user, and for that I need to know how many repetitions were performed in each test scenario. I keep my code down, Defines…
-
0
votes1
answer189
viewsHow to extract data from simple non-standard texts?
I would like to extract fields for a database from text files. However the fields are positioned in different ways in each text being difficult to obtain the values by common methods, for example:…
-
0
votes1
answer709
viewsDjango-admin.py execution error on Django 1.9
I am trying to learn Jango and would like to understand this notification I get every time I run the Django-admin command! Note that only Django core Commands are Listed as Settings are not properly…
-
0
votes3
answers115
viewsMultidimensional array
I am trying to create a multidimensional array. I first intended to place all the first elements with value 2 so I did: l=4 x=6 TSup=[ [ 2 for i in range(l) ] for j in range(x) ] print TSup and I…
-
0
votes0
answers54
viewsHow to connect dialog boxes in Qtdesigner and run py from them?
I’m new to programming in python and I already have some doubts. A friend created for me two codes in py using pu 2.7, Numpy and Scipy. I created an interface for these codes but don’t know how to…
-
0
votes1
answer131
viewsInitial input of a list after using set
I used this code initially to aggregate in dictionaries the values of B which had equal value in A: A = [12, 15, 10, 15, 12, 10, 10, 10, 15, 12, 12, 15, 15, 15] B = [0.2, 0.3, 1.1, 0.2, 0.2, 0.7,…
-
0
votes2
answers16389
viewsRemove Python punctuation and symbols
I’m trying to remove the punctuation symbols and other symbols (characters like copyright, for example) from a string. I want to leave the accented characters, the hyphen, the apostrophe ('), the…
-
0
votes1
answer818
viewsI need to know the size of a file even before it is created
I’m on a college job and it’s hard to solve... it’s like those wordlists that hackers use, but it’s for didactic study. QT: Generates a file with all possible groupings using the concept of simple…