Learning record:
Digital Type #
# integer int
# 100 = # Number int (100)
# number2 = int (100)
# Print (Number)
# Print (number2)
# float a float
# # a float SAL = 15.0 (15.0)
# = SAL2 a float (15.0)
# Print (SAL)
# Print (SAL2)
# type string
# name = 'Tank'
# = NAME2 "Tank"
# Content = '' '
# 1r1r1r
# 21r12r1
# r12r
# 12r1r21
# r12r1r2
# 12r1r
#' ''
#
# Print (name, NAME2, Content)
# Python strings may be added, multiplied
# Print ( 'Tank' *. 5)
# Print ( 'Tank' + 'Jam')
# Print ( 'Tank', 'Jam')
# type list
# [] brackets separated by commas, can be stored a plurality of different types of values.
# List1 = [ 'Zhang Man-Man', 'tank', 'Tu Yi Lei',. 11, 1.0, [ 'Jason', 200 is]]
# Print (List1 [0])
# Print (List1 [. 5] [0])
# dictionary type
# in the {} are separated by commas, can be stored a plurality of values, each value key: value stored in the form
# memory
# dict1 = { 'name': "tank", "age": 18} # name = { "Tank", "Age"} = 18 is
# take
# Print (dict1 [ "name"])
# boolean
# True or False
# Print (10 == 10) True #
# Print (== 10. 11) False #
# Note: All data types Boolean own, 0, None, are empty False
# 0 IF:
# Print ( '111')
#
# None IF:
# Print ( '111')
#
# IF []:
Print # ( '111')
#
# the else:
# Print ( '222')
# Formatted output
# to be replaced once the string type output
#% s placeholder,% d numeric type can be replaced
# Number = input ( 'Enter:')
# str1 = '' '
# Dear user, your credit balance is% s yuan.
# '' '% Number
#
# Print (str1)
# for cycle
# List1 = [. 1, 2,. 3,. 4,. 5]
# for Line in List1:
# Print (Line)
# for Line in Range (. 1, 10) :
# Print (Line)
# dict1 = { 'name': "Tank", "Age":} 18 is
# Key in dict1 for:
# Print (Key)
# Print (dict1 [Key])
operation:
name = "Alex"
Print (name.strip ())
Run Results: Alex
# 2) determines whether the value corresponding to the variable name to " al "at the beginning, and outputs the result
name =" aleX "
Print (name.startswith (" al "))
run results: False
#. 3) corresponding to the variable name is determined whether the value of an" X "at the end, and the output
name =" aleX "
Print (name.endswith (" X-"))
run results: False
#. 4) corresponding to the value of the variable name in the" l "is replaced with" p ", and outputs the result
name =" Alex "
Print (name.replace ( "l", "p") )
run results: APEX
#. 5) the variable name corresponding to segmentation according to "l", and outputs the result.
= name "Alex"
Print (name.split ( "L"))
Run Results: [ 'a', 'eX '
print (name.lower ())
Run Results: Alex
#. 8) corresponding to the variable name requested output value of the second character
name = "Alex"
Print (name [. 1: 2])
Run Results: A
#. 9) output Please name variable value corresponding to the first three characters
name = "Alex"
Print (name [:. 3])
run results: al
rear # 10) make the output value of the name corresponding to the variable two character
name = "Alex"
Print (name [-2:])
run results: X-
#. 11) corresponding to the variable name requested output where the index value "e" location
name = "Alex"
Print (name.find ( 'E'))
result: 3
# 12) acquisition sequences, removing the last character. Such as: oldboy then get oldbo.
= name "Oldboy"
Print (name [0: -1])
Run Results: oldbo
--- end --- restore content