I’m trying to use tkinter with python3 to open an image, see here a piece of code : I have installed python3-tk, and I have the demo window when I write in the terminal. I tried several combinations that did not work : gives , gives I tried with _tinker , FileDialog, file_dialog, but I always have “ImportError : cannot
Tag: python-3.x
Python – Brute force generator
I’ve made a brute force password cracker which works, but I also made a string combining generator which would be better as the brute force string generator; however I can’t figure out how to combine the two. Brute force code: Character generator code: I would like to replace the “Generating” section from the brute force code with the improved generator
How do I remove 1 instance of x characters in a string and find the word it makes in Python3?
This is what I have so far, but I’m stuck. I’m using nltk for the word list and trying to find all the words with the letters in “sand”. From this list I want to find all the words I can make from the remaining letters. In this case I have to use all the letters to find the words
find words of length 4 using regular expression
I am trying to find words in regular expression with length 4 I am trying this but I am getting an empty list: What is wrong with my code ? my input is: here we are having fun these days my expected output: [‘here’, ‘days’] my output: [] Answer Use word boundaries b. When you add anchors in your regex
Python3 exec, why returns None?
When the code below this text, and returns the result None why? Result: Module code exx.py: Answer The problem of course is not only that print returns None, it is that exec returns None, always. If you’d need the return value, you’d use eval: after which you’d notice that print still returns None…
How to create a pivot table on extremely large dataframes in Pandas
I need to create a pivot table of 2000 columns by around 30-50 million rows from a dataset of around 60 million rows. I’ve tried pivoting in chunks of 100,000 rows, and that works, but when I try to recombine the DataFrames by doing a .append() followed by .groupby(‘someKey’).sum(), all my memory is taken up and python eventually crashes. How
Upload Image using POST form data in Python-requests
I’m working with wechat APIs … here I’ve to upload an image to wechat’s server using this API http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files I’m not able to post data Answer From wechat api doc: Translate the command above to python: Doc: https://docs.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file
Reduce multiple blank lines to single (Pythonically)
How can I reduce multiple blank lines in a text file to a single line at each occurrence? I have read the entire file into a string, because I want to do some replacement across line endings. This doesn’t seem to work and nor does this It’s easy enough to strip them all, but I want to reduce multiple blank
Conditionally add items to a list when defining the list?
Is there a way to add items to a list conditionally, when defining the list? Here’s what I mean: Obviously the above code doesn’t work, but is there a similar way? Currently I have But I was wondering if there’s an other way that wouldn’t required looping through the list, since they can be 10 000 items long and the
Django 1.7: how to make ManyToManyField required?
I have a Django Model with ManyToManyField in it. I need to require user to select at least one M2M value in this field. I tried to set blank=False to M2M field but it didn’t help. I can solve this situation with custom Form definition or with override save() method for Person model. Is it possible to prevent create Person