What is garbled Chinese characters when Python connects to the database? We often encounter this problem. In fact, this problem is quite simple. Next, let's take a look at the technical issues related to Python database connection. I hope you will be helpful.
Maybe the charset is not set correctly when you connect to the database.
How to Use python exe?
Assume that there is a Python script named "hello. py" that uses a setup. py script to generate an executable file.
- from distutils.core import setup
- import py2exe
- setup(console=["hello.py"])
Replace the file name in setup (console = ["..."]) with the script file name to generate the exe. Then, execute this command line
- script:setup.py py2exe
A dist directory will be generated in the current directory. This directory contains the executable file and other required files, which must be published together.
How can I compile python into pyc and pyo?
- python -m py_compile exaile.py
Compile to a pyc File
- python -O -m py_compile exaile.py
The preceding section describes how to connect Python to a database.