Python Road Eighth _socket_2

Source: Internet
Author: User

Python class import and assertion

Create a new Python package and create a new class inside it. 2. Create a new Python file under the statistics directory of the package, and import the contents of the Python package. and asserts whether this result is a string. The following are the specific examples:

1 class Dog (object): 2     def __init__ (self): 3         Self.name ="haha"
1 Importimportlib2AA = Importlib.import_module ("Lib.aa")3 Print(Aa.dog (). Name)4 5 assertType (Aa.dog (). Name) isStr#assert that he is a string in order to perform the subsequent content6 7 Print("AA")
In reviewing the problem of Python3 coding

The default encoding in Python3 is bytecode, which is bytes. A binary format must be in the data transfer, so it must be cast to the Uncode format.

UTF-8 encoding: Is the compression and optimization of Unicode encoding, he no longer uses a minimum of 2 bytes, but all the characters and symbols are categorized: the contents of the ASCII code is saved with 1 bytes, the characters in Europe are saved in 2 bytes, and the characters in East Asia are saved in 3 bytes.

Here's how to convert

Python Road Eighth _socket_2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.