Newest python Questions

Q&A for professional and enthusiast programmers

Character encoding when reading a csv file

I am reading a list of urls from a csv file and am getting these 'AC0' etc. for where there are hyphens in the url. I have tried using .encode('utf-8') etc but not had any success so far. with open('...

python regex to group numbers

im trying to caputre numbers from that kind of a string: "30098.904999 5 ABC Da d 8 06 01 20 00 80 11 C0 04" first i remove all whitespaces: test = ' '.join(test.split()) ...

Using python 3 to fill in text boxes on websites, and clicking button to download

I want to download youtube videos with python. I found a website (https://www.youtubeinmp4.com/) wich can download youtube videos in mp4 format. I am using python 3, BeautifulSoup and requests to get ...

Python3.5+uWsgi during benchmark provide error the timeout

I make a server with Python3.5 + uwsgi + nginx + flask. And i tried to make apache benchmark tests but got such error ab -n 100 http://xxx.xxx.xxx.xxx/speedtest Benchmarking xxx.xxx.xxx.xxx (be ...

How to stop updating a list in realtime? [duplicate]

I have this code sample: actionList = [] combinedList = [] actionList.insert(0,"asdasda") actionList.insert(1,"tuty") n = 0 combinedList = combinedList[:n] + [actionList] print("combinedList ...

Failed to install wsgiref on Mac

I have a problem on install wsgiref on Mac. $ python --version Python 3.6.0 :: Anaconda 4.3.1 (x86_64) $ pip --version pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6) My ...

Highlighting tile on Pygame tilemap

I'm making a simple tile-based game with Pygame. Currently, it displays a 10x10 grid of randomly selected tiles. That part is working perfectly, but I have a problem with highlighting. When you ...

Python: Stuck on final piece of Knapsack Calculation

I am almost done calculating my knapsack problem. I have a list of items with their weights (lbs) and value. And my knapsack cannot exceed 11 pounds. I cannot figure out the last piece of code ...

Can't get the username id in the url Django

Here is my view.py def Profil (request, username): user = User.objects.get(username=username) return render(request, 'blog/Profilvisitor.html', {}) And here the index.html <a href="{% url '...

extracting data from a text file (python)

i have two columns of numbers in a text file which is the columns of time and stress respectively which i get it from an analysis in abaqus finite element package ! i want to extract the time column ...

tkinter window checkbox operation

'''my check box(admin_check) is not setting values in check_var while being toggled when i remove root window it works fine but i can not remove it view its necessity''' def c(): print(check_var.get()...

Is there another way to print tuples than to use the Enumerate funciton

Is there another way to return a list of tuples for the index and the item in the list without having to use the enumerate function? This is for python 3 and greater.

How do I send files in an email by using the Python email module?

I heared, that you can send files per email using the email module. How do I do that?

ThreadPoolExecutor process the identical parameter when iterating a queue

As a newbie, I am currently working on a multithreading crawler.But I've run into the problem of the sharing of urls. Here is a piece of my code: executor = ThreadPoolExecutor(max_workers=4) executor....

what is this b'Y \x84\x0b\x08\x00\x00\x01\x00\x00\x00\x1e\x00\x01\x00T\x00r\x00i\x00g\ [on hold]

evtx file using python in 'rb' mode iam getting output something likethis 00l\x00a\x00t\x00f\x00o\x00r\x00m\x00U\r\xcc\xb6\xcc\x9e\xa8I\xb9)+\x90"Bo*M\x00i\x00c\x00r\x00o\x00s\x00o\x00f\x00t\x00-\...

Python loop and listing issue [duplicate]

Can anyone help me with my code, I just cant seem to see the problem. I am new yo programming so it probably really easy to see. I am using 4 birthday gifts as an example. x = input("How many ...

Python Scrapping, Web page doesnot exist but the website redirects to another page

i am trying to find a way to know that if a web page exists or not. there are plenty of methods like httlib2, urlparse and using requests . but in my case the website redirects me to the home page if ...

TensorFlow weights increasing when using the full dataset for the gradient descent

I wrote an article explaining in depth how a neural network works from scratch. To illustrate the blog post, I wrote the neural network in python using numpy and I wrote a version using TensorFlow. I ...

why is there a difference when assigning value to a dict initialised with dict.fromkeys() and with curly braces?

This is an example, my_keys=['hi','hello'] d=dict.fromkeys(my_keys,[]) print d d['hello'].append([1,]) print d['hello'] print d['hi'] d={'hi': [], 'hello': []} print d d['hello'].append([1,]) print ...

Calculating percentage with Pymongo project and devide returns None

I'm currrently learning Python - so this might be a quite easy question for you. However, I did not find a solution while browsing, so I hope to find help here ;) I want to get the percentage of the ...

Tensorflow - Does Weight value changed in tf.nn.conv2D()?

While I'm studying about Neural Network with tensorflow, I got a some question about tf.nn.conv2D(x, W, strides=[1, 1, 1, 1], padding='SAME') When I input image value x, and weight value W(initailzed ...

want to automate R and Photoshop connecting them with a click?

To run a program in R .Do some modifications on the graph with Photoshop and upload it on net through python. Is this possible?

How to add custom-fields (First and Last Name) in django-registration 2.2 (HMAC activation Workflow)?

There are already some question on this but most of their answers are using models based workflow which is not a recommended way anymore according to django-registration. I am just frustrated from ...

how can i kill all the zombie process on my computer?

i am trying to find a running process by it's but zombie process interrupt me- because of it i can't Determine if the process itself is running. for pid in psutil.pids(): try: p = psutil....

Recording sleeptalk with python - filtering ambiant noise

I made this by taking inspiration from Detect & Record Audio in Python and did this : #taken from http://en.stack.aiseen.org/questions/892199/detect-record-audio-in-python #Added : # # - record ...

Converting String of a given alphabet to an integer

I have a working function that converts an integer to a string of length k over a given alphabet A def ToString(x, k, A): """ Args: x (int): Integer x ∈ N k (int) ...

What's the base implementation difference in training SVM models in scikit-learn and MATLAB?

I have university project to analyze EEG signals. I've processed the signal using MATLAB and Python in the following way: Choose the appropriate channel 19000 * 59 ==> 19000 * 7 Filter that ...

Iterate dictionary in django template

I have a dictionary >>> filterdata {u'data': [{u'filter': u'predictions', u'filtervalue': u'32', u'filterlevel': u'cltv', u'filtertype': u'>'}, {u'filter': u'profile', u'filtervalue': u"'...

Python dictionary printing first word behaviour

I'm learning python and am on the topic of dictionaries. I wrote the following dictionary: Team={ ('projectmanager','Asma'): 'Sara', ('ba','Richard'): 'Steve', ('tester','Asma'): 'Rob', ...

Rpy2 and Django Error: C stack usage 69077360 is too close to the limit

I am creating a django project in Windows in which I need to call few existing R codes (saved as .R files) via django views functions. To achieve this, I am using rpy2 python library. After including ...

expand grid in python [duplicate]

I'm trying to run a code in python that creates all possible combinations of different variables value. in R the code will look like that: a=unique(df$a) b=unique(df$b) c=unique(df$c) d=unique(df$d)...

Getting error with gRPC ruby / python client

Following is my protobuf defition: syntax = "proto3"; package hello; service HelloService { rpc SayHello(HelloReq) returns (HelloResp) {}; rpc SayHelloStrict(HelloReq) returns (HelloResp) {};...

unsupported operand type(s) for +: 'int' and 'dict' [on hold]

I am having an issue which I just don't understand. It says there is some issue with the sum function, but I just cannot get my head around it. grade_values = { "a+" : 4.4, "a" : 4.0, "a-" : 3.6, "b+"...

Error in installing scikit-learn in ubuntu

When is try to install scikit learn, im getting this error, I used "pip install -U scikit-learn[alldeps]" """Collecting scikit-learn[alldeps] Using cached scikit_learn-0.18.1-cp27-cp27mu-...

OpenALPR: Cannot run train.py for new country licence plates

I'm using Ubuntu 16.04 to run OpenALPR. I installed it and produced font tiles from the TTF font files for my country, but ran into problems using train.py. It's supposed to produce [countrycode]....

Unable to log in to a website using python requests

I'd like to be able to log in to the website http://www.rankk.org/ to be able to read a certain challenge, for instance the first one with the URL http://www.rankk.org/challenges/really-elementary.py. ...

Pip install Scrapy “codec can't decode byte”

I'm trying hard to install Scrapy, first time I tried I've get error about vcvarsall.bat, I was trying some solutions but nothing worked so I reinstall Visual Studio Community 2017 and dev tools, and ...

Indexing with multiindex dataframe in pandas

My data looks like this So, How can I query the dataframe only with the second level index Patient only? For example, I'd like to know all the data with respect to Patient 2. I've tried data[data....

Pythonic way to construct these strings

Lets say I have two arrays, one is a string lets say "ABCD" the other is an array of bits (1010). I want to construct a new string from the initial "ABCD" that follows this pattern, 1 meaning take ...

How to plot a geometric graph in Python?

I want to build a class "GeometricGraph" as a dictionary, having its keys as the nodes of the graph and the edges between two nodes represented by tuples of the two corresponding keys. Each node is ...

Hello guys, may I ask for any kind of code review please? I would be very thankful for any piece of advice, thanks. :) [on hold]

I want to ask for any kind of code review about, what to improve in my code or how to make things more simple :) . As long as i am just a beginner and have not been coding before. :) I would be very ...

Browse list in python and get data

I want to get the total number of views of a serie of videos on Youtube about a concrete topic. I have this code, but it doesn't work because I am not getting the correct data from the list "videos". ...

GameofThrones code

I need pass hackerrank code challenge. Can anybodey help with that mission? Constraints 1 ≤ length of string ≤ 106 Each character of the string is a lowercase English letter. Sample Input #00: ...

Opening file in py2app built program using macOS Sierra

(Noobwarning, just started trying to learn programming a few weeks back and are working with python 3.6 in intelliJ on macOS Sierra) Im working on a program that should read a text file and insert ...

pattern recognition 1d data

I want to find pattern in some spectra. Spectrum image Pattern should look like 2 in gray circles on picture, all data looks similarly. Light blue line is the original data, dotted dark blue line - ...

operate Oracle vm VirtualBox manager with python

Until now I was working with Hyper-V. Now I’m starting to work with “Oracle vm VirtualBox manager”. If you cloud guide me how to start and what SDK I need to download, I’ll be very thankful Launch a ...

Scraping hidden product details on a webpage using Selenium

Sorry I am a Selenium noob and have done a lot of reading but am still having trouble getting the product price (£0.55) from this page: https://groceries.asda.com/product/spaghetti-tagliatelle/asda-...

String formatting for Python datetimes with timezones using Pandas

I am having trouble parsing timestamps for my data using Pandas. An example of the datetime format that I am trying to parse looks like 2012-05-02 01:00:00-05:00. From the Pandas docs I was driven ...

paramiko mutiple commands as argument

I am working on automation. here i am facing challenge to execute n number of commands on Linux device concurrently or sequentially. Now i am using the below method but i have create static config for ...

How do I computes sum of each column?

I'm working on my study guide and I am stuck. Define a function named maxColumnSum that: Takes 1 parameter: a 2D list of integers (All sublists are of the same length). Computes sum of each column. ...
Translating... 0%