Create Python Program 2

Source: Internet
Author: User

After editing it in Milang IDE, press F5 to run it. Then, "Hello, World!" will be Output in the Output window below !" String, such:

 

Congratulations! The simplest Python program you have written has been completed and has become a Python programmer. It is so easy to get started with a language.

Through the simple program above, we can see that the Python program runs directly without compilation. Based on this program, you can modify its output, such as Hello, World! Change to Hello, CSDN, or other sentences that make sense. Or you can divide "Hello, World" into two print () function outputs to see how it works.

By the way, the above program only outputs English strings. to output Chinese strings, you still need to work hard. Because the expression of Chinese in a computer is much more complex than the expression of 26 English letters, in the early days of the computer, in order to make a variety of Chinese cards for Chinese output, it took a lot of effort. In today's perfect graphic system, the expression of Chinese characters is still complicated. For example, when we see that Chinese characters are a word on the interface, they are actually expressed in two bytes in the computer. Although there is only one byte, there is only one more byte, which brings many problems in the system today. For example, a mix of Chinese and English can have a variety of solutions, some all use two bytes to express Chinese and English; some use two Chinese bytes, while English uses one byte; some adopt more than two Chinese characters, and English adopts a mixture of one byte. When there are two Chinese bytes, we pay attention to the first byte, which is followed by the problem, because the order of the two bytes on different CPUs is different. If the computer was invented by China at the beginning, it may become simpler. All the bytes are not the 8-bit of today, but 16-bit as one byte, so many problems will be much simpler. Even when software developers develop software today, they still commit this issue many times, which costs a lot to solve it.

The following describes how to write a Python program to output Chinese characters:

#-*-Coding: UTF-8 -*-

Print (r "whisper, hello! ")

In this example, it is a little different from the previous example. Not only does the string become Chinese, but there is a lower-case letter r in front of the string, this is used to indicate that the line string uses the original encoding method and does not need to be converted, so that the encoding of the Chinese string remains unchanged and the original output can be kept in the result output window. The following window is shown:

 

Through this example, we learned how to output Chinese characters, laying a solid foundation for writing more functional programs later.

 

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.