Decoding UTF-8 strings in Python

You need to properly decode the source text. Most likely the source text is in UTF-8 format, not ASCII. Because you do not provide any context or code for your question it is not possible to give a direct answer. I suggest you study how unicode and character encoding is done in Python: http://docs.python.org/2/howto/unicode.html

How do I remove a substring from the end of a string?

strip doesn’t mean “remove this substring”. x.strip(y) treats y as a set of characters and strips any characters in that set from both ends of x. On Python 3.9 and newer you can use the removeprefix and removesuffix methods to remove an entire substring from either side of the string: The relevant Python Enhancement Proposal is PEP-616. On Python 3.8 and older you can use endswith and slicing: Or a regular expression:

Git push won’t do anything (everything up-to-date)

git push doesn’t push all of your local branches: how would it know which remote branches to push them to? It only pushes local branches which have been configured to push to a particular remote branch. On my version of Git (1.6.5.3), when I run git remote show origin it actually prints out which branches are configured for … Read more

Import error when trying to import tensorflow with gpu

If you are using TensorFlow with GPU, you need to install CUDA and cuDNN. Please follow instructions on https://www.tensorflow.org/install/ If you have already install CUDA and cuDNN, but still get this error, then you probably forgot to export your libraries: for Linux, you may need to set LD_LIBRARY_PATH to include CUDA libraries.

split python source code into multiple files?

I am researching module usage in python just now and thought I would answer the question Markus asks in the comments above (“How to import variables when they are embedded in modules?”) from two perspectives: variable/function, and class property/method. Here is how I would rewrite the main program f1.py to demonstrate variable reuse for Markus: … Read more

What is the difference between isdigit() and isnumber()?

isnumber() may be an Apple-specific C++ method (I don’t have a Mac on hand to check). You can see it in the Apple dev guide: The isnumber() function behaves similarly to isdigit(), but may recognize additional characters, depending on the current locale setting. Besides, isnumber() is not declared on Linux: I use g++ 6.1.1 on Linux 4.7.2 and get the error: I … Read more

Correct mime type for .mp4

According to RFC 4337 § 2, video/mp4 is indeed the correct Content-Type for MPEG-4 video. Generally, you can find official MIME definitions by searching for the file extension and “IETF” or “RFC”. The RFC (Request for Comments) articles published by the IETF (Internet Engineering Taskforce) define many Internet standards, including MIME types.