Basic knowledge of Python learning notes (2)

Source: Internet
Author: User

1. Input and output:

Output: print, as follows

>>> print ' Hello world '
Hello World

Inputs: Input (), Row_input ()

The recommended use of row_input (), input () will default to the data type you entered is correct, resulting in some errors, unless specifically required, try to use Row_input

>>> name = Raw_input ("What Are you name?")
What are you name? sola
>>> Print Name
Sola

2. String

A, long string

If you want to write a very long and long, to span a few lines can use three quotation marks, as follows:

>>> print ' What is laughing at?
... I don ' t know what's that mean
... sorry! "

B, Raw string

Like "\ n" These strings with backslashes will have a newline, or other escape effect, so for example, when we want to print an object directory (such as D:\nothing\that), an unnecessary error occurs.

But the original string does not have special treatment for these backslashes, the original string, as long as it starts with R before the string, as follows:

>>> print ' D:\nothing\that '
D:
othing hat
>>> print R ' D:\nothing\that '
D:\nothing\that

C, Unicode string

This detail is not quite known, the usage is similar to the original string, with a u in front of the string, as follows

>>> print u ' Hello World '
Hello World

3. Some functions

Pow (x,y[,z]) #返回x的y次幂 (resulting in Z-modulo)

Round (Number[,ndigits]) #根据给定的精度对数字进行四舍五入

Basic knowledge of Python learning notes (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.