Skip to content
Advertisement

Tag: python-3.x

Tkinter import filedialog error

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

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

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…

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

Advertisement