Questions tagged as 'python'

3
answers

Annotate: Returning the cheapest product and vendor name (Django)

Given the following table product;company;price AAAAA;forn1;395.69 BBBBB;forn1;939.45 CCCCC;forn1;480.33 DDDDD;forn1;590.59 EEEEE;forn1;847.69 AAAAA;forn2;227.31 BBBBB;forn2;375.90 CCCCC;forn2;602.18 DDDDD;forn2;615.02 EEEEE;forn2;84...
asked by 03.09.2015 / 18:32
1
answer

Adding a comma to a string

Good personal and possible add comma in an example string: a = '1234567890abcdefghijklmnopqrstuvwxyz_' So that she stays like this a = 1,2,3,4,5,6,7....     
asked by 04.12.2015 / 22:13
1
answer

Calculating a magic square

I'm trying to make a magic square: A magic square is one that is divided into rows and columns, with a number in each position and the sum of rows, columns, and diagonals is the same. Example (3x3 - no. 1 to 9): 8 3 4 1 5 9...
asked by 21.11.2015 / 19:00
1
answer

How to use arguments passed to a python script?

In scripts php, we can, when executed by the command line, capture its values of the arguments passed through the variable $argv and its number through the variable $argc . For example (Script): echo 'My name is ', $argv...
asked by 15.02.2016 / 14:32
2
answers

How to fix error "TypeError: must be unicode, not str" in Python?

When backing up my database in Sqlite3 , the Python interpreter returns the following message:    TypeError: must be unicode, not str on line f.write("%s\n" % linha) , I could not find a solution for this error. Follow the code:...
asked by 25.08.2015 / 19:30
2
answers

Error parsing image in half using Python

I'm trying to split an image in half using the code below, but I'm having a return error. Code: import cv2 import numpy as np # Read the image img = cv2.imread("IMD015.png") width = img.shape # Cut the image in half width_cutoff = width /...
asked by 15.11.2018 / 19:25
2
answers

How to open a unicode file inside a zip?

I've tried with zipfile.ZipFile("5.csv.zip", "r") as zfile: for name in zfile.namelist(): with zfile.open(name, 'rU') as readFile: line = readFile.readline() print(line) split = line....
asked by 16.12.2013 / 01:45
1
answer

Why fractions.Fraction (1/3) does not return "1/3"?

import fractions a = int(input()) b = 1 / a b = fractions.Fraction(b) print(b) This is part of a code I'm developing. This part had the function of taking the decimal resulting from the division "1 / a" and transforming it into fraction and ap...
asked by 03.01.2019 / 18:45
3
answers

Run Python and C # together

How can I in C # import, that is, execute some script in another language (Python)? Example: If you write "R" in a program in C #, it executes a file named ApertouR.py .     
asked by 27.12.2017 / 13:59
2
answers

Difference between commands to stop execution

I've noticed that there are several ways to stop a run. Basically what is the difference between using the commands: break; sys.exit () (From the sys module); os._exit () (From the the module); exit (); quit (); I...
asked by 24.10.2018 / 16:59