Posts by weltonvaz • 343 points
24 posts
-
1
votes3
answers4009
viewsA: How does the python sys module work and what is it for?
The sys module allows using stdin() and stdout(), as well as stderr(), but more interestingly, we can use sys.argv() . For many, this is a confusing concept, but it is quite simple and very useful…
python-3.xanswered weltonvaz 343 -
1
votes1
answer569
viewsA: Error reading a column of a file . xlsx using Python pandas library
I believe that this should work import pandas as pd from pandas import DataFrame df = pd.read_excel('email.xlsx', sheet_name='Planilha1') email = df['EMAIL'].values.tolist() print(email)…
-
0
votes2
answers765
viewsA: Read file in previous python folder
In Python, to move a file to another directory just use the shutil module: import shutil shutil.move("cvcompacto", "/../statics/downloads/")
-
0
votes1
answer25
viewsA: Send text fixers by python smtp
More or less the same way, using msg.attach: from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart msg = MIMEMultipart() filename = "text.txt" f = open(filename,'r')…
-
0
votes1
answer68
viewsA: How to perform a draw in python following a certain distribution, such as Gaussian or Maxwell-Boltzmann distributions?
The scipy module has the integrated Maxwell-Boltzmann distribution, the Random module only has the Gauss method. The scipy module is better and with greater statistical ability and will give you the…
-
0
votes1
answer40
viewsQ: Reference between two tables by Heidisql
Friends, I am using Heidisql and I have a database: Mariadb created two tables and I want to reference client table id, with user_id of table posts. And I forgot how to reference, using the app…
-
0
votes1
answer301
viewsA: How to pass Matlab to python?
To start the MATLAB® engine in a Python session, you must first install the engine API as a Python package. MATLAB provides a standard Python setup.py file to build and install the mechanism using…
-
-1
votes2
answers1649
viewsA: What is the underscore (or underline _ ) for in the repeating structure?
The underscore prefix serves as a hint to another programmer that the variable or method starting with a single underscore is intended for internal use. This convention is defined in PEP 8. This is…
-
0
votes2
answers41
viewsA: Doubt about inserting content from a file . txt to a list
The method open opens the file and returns a Textiowrapperobject, but does not read the contents of the files. To really get the contents of the file, you need to call the method read in that…
python-3.xanswered weltonvaz 343 -
1
votes0
answers330
viewsQ: Error of Memory in Python
I’m tempted to days solve this problem and can’t, my scripts works on various python machines, but on the server I need to run the application and presents the error, I’ve left a memory test running…
-
0
votes1
answer95
viewsQ: Doubt about object orientation in Python
I’m a classmate we were doing a script I wrote my script in this way: detalhes = programa.duracao if hasattr(programa, 'duracao') else programa.temporada In my case, I’m calling it that way! My…
-
1
votes1
answer3835
viewsQ: Read specific line of a txt file
I have a file of 1000 lines and I want to read line 952. I don’t want to have to use a loop to go through all these lines, there’s some more optimized way to do this?
-
-2
votes2
answers66
viewsQ: List counting elements
I have a list, like this: L = [0, 0, 1, 1, 1] If you used the command SET: L = [0,1] sum(L) = 2 The answer I need would be: 3. Each pair of answers would be one point, as it has two '0' = 1, one…
-
0
votes1
answer122
viewsQ: Python Problems with Too Big List
I’m making a Python script and I’m getting an msg error I can’t fix x = [int(e) for and in input(). split()] msg of error: Memoryerror Command exited with non-zero status (1) tried to use map: x =…
python-3.xasked weltonvaz 343 -
-1
votes1
answer1290
viewsA: Pycharm build error: can’t find python libraries 3.6
Modifying the interpreter in Pycharm Go to Settings (File >> Settings), In the side menu find the Project option and inside it Project Interpreter, on the right screen select the desired…
-
0
votes1
answer852
viewsA: python3.6 URLLIB Request
Friend, Although you speak python3, you are using python2 when running the script! Your code worked perfectly on my python3.6! Now the procedure changes a little if you use python2, you have to use…
-
1
votes1
answer38
viewsQ: In this case below, wouldn’t the login attribute have to be set as private for the method?
I am studying inheritance in Java and one of the exercises has the code below, I think, the login attribute would not have to be set as private for the method? public class Gerente extends…
-
1
votes2
answers135
viewsA: Adding points in a known data range
Following your tip, I read the documentation of Numpy and Scipy, and using numpy itself that has a function called "interp" (as in the documentation above), but my preference is for the package…
-
0
votes2
answers135
viewsQ: Adding points in a known data range
I am working on data analysis using Python and for this I am training SVC and K-Means algorithms. The data used for the training have a fixed spacing between each sample, because they are sampled by…
-
0
votes1
answer185
viewsA: How to use Python integrated with . CSV
You can do it in various ways, but the most usual is: import csv with open('214385.csv') as f: f_csv = csv.reader(f) headers = next(f_csv) for row in f_csv: # Process row print(row) link:…
-
1
votes1
answer812
viewsA: Comparison between two Python objects using id() function with different result
In reality you did not create two instances in: >>> id(Carro()) == id(Carro()) # True that’s why True: See the code below, it works on python2 or python3 >>> from carro import…
-
1
votes1
answer132
viewsA: Recursion in Python
There’s too much wrong, come on: Apparently, you want to identify if a list contains sublists. On line 3, your if just exchange the boolean value and does not generate a condition, the return will…
-
4
votes3
answers9505
viewsA: Difference between dates/times in Python
I found a solution by searching the DATETIME function s = '2015/08/05 08:12:23' t = '2015/08/09 08:13:23' date1 = int(datetime.datetime.strptime(s, '%d/%m/%Y %H:%M:%S').strftime("%s")) date2 =…
-
3
votes3
answers9505
viewsQ: Difference between dates/times in Python
I need to calculate the difference between two dates in python, but always some error. >>> from datetime import datetime >>> data1 = datetime(2015, 8, 5, 8, 12, 23) >>>…