Class notes------python data type (bottom)

Source: Internet
Author: User

#转义字符
#转义字符就是让一个有意义的字符变得无意义或无意义变得有意义;

#将有意义的字符变得没有意义
Home = ' 27\ ' 28\ '
Print (Home,type (home))

#将无意义的n变为有意义的换行操作
Home = ' My home is on the Songhua River in the northeast, '
Print (Home)

#其他的转义字符
#\\ represents a character \
#\r indicates return to the beginning of the current line

Home = ' \\huijia\\ home '
Print (Home)

Home = ' Go back, go home, go home \ R ' I'm Going Home '
Print (Home)

#\ indicates the continuation of the line symbol at the end of a row
Home = ' Go back, go home, go home, I'm going home, \
Go home now. "

#原字符串: Escape character in string is not escaped, output string as-is
Maxam = R ' Gengkeyufang\\donglei\n,baochishoubu\rjifurunhua '
Print (Maxam)

#list list type identification [] can modify content
Listvar = [' 123 ', ' 234 ', ' 345 ']
Print (Listvar,type (Listvar))

#tuple tuple type, identity, non-modifiable
Tuplevar = (' 222 ', ' 333 ', ' 444 ')
Print (Tuple,type (Tuplevar))

#dict dictionary type, identity {}
Dictvar = {' Key1 ': ' 123 ', ' Key2 ': ' 222 '}
Print (Dictvar,type (Dictvar))

#set collection type has no glyphs
Setvar = {' age ', ' value ', ' name '}
Print (Setvar,type (setvar))

About assigning values to variables

#普通赋值
var = ' ingredient '
Print (VAR)

#多变量赋同一个值
var = var1 = Var2 = ' case '
Print (VAR)

#多变类赋不同的值
var3,var4,var5= ' A variable ', ' B variable ', ' C variable '
Print (VAR3)


About Data transformations
1. Automatic data type conversion
1. Automatic data type conversion is performed automatically by the program and does not require manual intervention
2. The Word movement data type conversion occurs in the computation and the judgment process more
3. Automatic data type conversions are converted to more precise types

2. Forcing data type conversions

#自动数据类型转换
‘‘‘
1. Automatic data type conversion is performed automatically by the program and does not require manual intervention
2. The Word movement data type conversion occurs in the computation and the judgment process more
3. Automatic data type conversions are converted to more precise types
‘‘‘

Ivar = 15
Fvar = 3.5
RST = Ivar+fvar
Print (Rst,type (RST))

If 5>3:
Print (' true ')
Print (' 5da ')

Class notes------python data type (bottom)

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.