Python variable data type-string two

Source: Internet
Author: User

This is the content of the December plan, beginning in January 2018 ~

If there is any mistake, please ask for it ~

Python Print Function One

Variable assignment in Python does not require a type declaration, okay, well, that's OK.

We can also take a look at the type

1 num=1.2332 str="1.233"3print(type (num))  4print(Type (str))
<class'float'><class'str'>

Data Type- string

Single quote, double quotation mark usage same

1 str="1.233"2 string='1.233'3 Print (str) 4 Print (string)
1.2331.233

A string that represents multiple lines in three quotation marks

1 str="ASDASD2asdasdasd3asdasdasd4 Adas " " 5 Print (str)
Asdasdasdasdasdasdasdasdadas

There are all kinds of escapes ... I think it's OK to remember a little bit of the usual, and then look it up when you use it.

Escape Character Description
\ (at end of line) Line continuation character
\\ Backslash symbol
\‘ Single quotation marks
\" Double quotes

and its operators.

+,* all said, let's take a look at [],in,not in

1 str="helloworld"2print(str[1])3  Print(Str[1:4])# interval is left closed right open, note negative number is right to left 4print(str[:5]) 5 Print (str[4:])
Eellhellooworld
1 str="helloworld"2print("H" inch str) 3 Print ("H" not in str)
TrueFalse

R or R, original string-original string: All strings are used directly as literal meanings, and no special or non-printable characters are escaped. Escape can't remember, you can use this.

1 str=r"D:\eclipse\readme"2print(str)
D:\eclipse\readme

Finally it's internal function, play it by yourself ~ There will be a summary later.

Python variable data type-string two

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.