How to install Python correctly?

Source: Internet
Author: User

When installing Python, you should pay attention to the relevant knowledge. The so-called Python is an object-oriented, literal translation computer programming language, and also a powerful and complete general-purpose language. Currently, technologies based on this language are rapidly developing.

First, you need to know that Python has two types of strings (strictly speaking, this does not seem to be the case ). One is an ordinary str object, each character is represented by 8 bits), the other is a unicode string, they can be converted to each other. Open pyshell and enter a piece of code.

For The two types of Strings, The Python documentation --> javasagereference --> DataModel --> The standard type hierarchy --> Sequences has some Strings and Unicode descriptions. As

 
 
  1.  >>> A="I"
  2. >>> B=Unicode(A, "gb2312 ")
  3. >>>A. _ class __<Type'Str'>
  4. >>>B. _ class __<Type'Unicode'>
  5. >>>

When encode is used and decode is used, it is always confused at the beginning. In fact, the English name of various local Character sets is Coded Character Set. to convert it to Coded, it must be an encode. Similarly, it should also be called decode ......

Decode converts other encodings to unicode, which is equivalent to unicode functions. encode converts unicode encoded strings to specific encodings. Continue In pyshell: a is of the Str type, so an error is returned when you use encode. When print is used, will the default encoding be called to convert to system encoding?

 
 
  1.  >>> A="I"
  2. >>> B=Unicode(A, "gb2312 ")
  3. >>>A. _ class __<Type'Str'>
  4. >>>B. _ class __<Type'Unicode'>
  5. >>>

Install the default encode and decode in Python in strict mode, so an Error is thrown directly, while the default replace mode is in Java, therefore, when processing Servlets, we often see a string ?????
When decode is passed in, the second parameter errors is set to 'replace ', which can be the same as Java, but it is always unsuccessful. Why?

 
 
  1.  >>> A="I"
  2. >>> B=Unicode(A, "gb2312 ")
  3. >>>A. _ class __<Type'Str'>
  4. >>>B. _ class __<Type'Unicode'>
  5. >>>

After trying for a long time, whether you specify charset = 'utf8' at connect, use set_character_set (), or execute "set names utf8" to track character_set_name () latin1... again with the code, it seems to have gone to mysql-api. The final solution is also very simple, that is, to execute it in the following way, rather than spelling SQL statements ......

As long as Python is installed, these functions are available in addition to the standard library, there are many other high-quality libraries, such as wxPython, Twisted, and Python graphics libraries. Python is easy to expand and embed. Many standard modules provided by Python support C or C ++ interfaces.

Python and C can work together and can be embedded into C or C ++ applications. Therefore, the Python language can be used to provide a script interface for the application. Because it supports cross-language development, you can use Python to design a conceptual application and gradually port it to C. You do not have to use C to rewrite the application.

(Jython enables Python to work with Java, so that developers can call Java packages in Python installation, or use Python objects in Java. Even better, because the Jython interpreter is fully written in Java, you can deploy Python programs on any platform that supports Java, and even run Python scripts on WEB browsers .)

  1. How to embed Python into C ++ applications?
  2. In-depth discussion of Ruby and Python syntax comparison
  3. Introduction to Python
  4. Python Learning Experience: version, IDE selection and encoding solution
  5. Analysis of Python GIL and thread security

Related Article

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.