The Secrets of Python You Didn't Know | String Concatenation

String concatenation is the process of merging two or more strings into one. While it may seem like a basic problem, in Python, there are multiple ways to achieve string concatenation. A poor choice can lead to performance issues. Method 1: Plus Operator Many languages support using the plus operator for string concatenation, and Python is no exception. Simply add two or more strings together to concatenate them. a = 'Python' b = 'Cuisine' r = a + b # Outputs 'PythonCuisine' Method 2: Using the % Operator Before Python 2.6, the % operator was the only way to format strings, and it can also be used for string concatenation. ...

June 28, 2018 · 3 min · Zhiya

Installing KVM Virtual Machine on Ubuntu 18.04 LTS

Recently, I installed KVM on the latest Ubuntu 18.04 to virtualize a small VM cluster. Here, I document the main process and some issues encountered. Preparation First, you need to check if the CPU supports virtualization. Run the following command to check if there are any virtualization-related terms in the /proc/cpuinfo file. If present, it indicates that the CPU supports virtualization technology. egrep -c '(svm|vmx)' /proc/cpuinfo If the command returns 0, it means the CPU does not support virtualization technology. Additionally, virtualization technology in the motherboard BIOS might not be enabled by default. If not, you need to enable it manually. ...

June 28, 2018 · 4 min · Zhiya

Major Issue! Uninstalling WeGame Solves XPS 15 Blue Screen Problem

Incubation Period At the end of April last year, I bought a US version of the XPS 15 9560. After using it for a few months, it occasionally started to blue screen. I had seen many complaints about XPS quality control on forums before, so I thought I was just unlucky. Fortunately, the blue screens were infrequent and didn’t affect usage, so I didn’t pay much attention. Escalation Period This May, after upgrading to Win10 1803 (I usually upgrade software immediately to experience the latest improvements), the blue screens became more frequent and started affecting usage. So, I began investigating the problem. ...

June 20, 2018 · 3 min · Zhiya

The Evolution of Python String Formatting You Didn't Know

String formatting is a fundamental and frequently used feature in every programming language. Those learning Python are likely familiar with using the % syntax for string formatting. However, to make this common feature more convenient, the language itself has iterated on string formatting methods. Before Python 2.6: % Operator Before Python 2.6, there was only one method for string formatting: the % (also known as the modulo) operator. The % operator supports both unicode and str types of Python strings, similar to the sprintf() method in C. Here’s an example of using % to format a string: ...

June 11, 2018 · 4 min · Zhiya

Essential for Beginners | Python Cheat Sheet Chinese Version

I have compiled a quick reference sheet for Python3’s built-in methods, which includes: Built-in methods List processing methods Dictionary processing methods Tuple processing methods Set processing methods Slicing methods for sequence types A total of over 100 methods. Click on the image—view original—download.

May 31, 2018 · 1 min · Zhiya