Day-10 magic string (II)

! # / the User / bin / env Python 
# - * - Coding: UTF-8 - * -
# ==================== seven ======= ===================

# the find ( 'xx')
# backward look from the beginning, after the first find, acquire its location
# specifies the note when looking for a location > =, <
Test = "alexalex |"
V = test.find ( 'EX')
Print (V)


# ==================== eight ==== ======================

# index ()
# and above all look the same sequence
# this is not the same as being given not find the former can not be found as to -1
Test = 'alexalex9'
V = test.index ( '. 9')
Print (V)
# ==================== nine ===== =====================

# first
# the format ()
# format; a string placeholder with the value specified
test = " {name} AM I, Age {A} "
V = test.format (name = 'Tom', A =. 19)
Print (V)

# second
# continuation scratch forever
= Test "I AM {0}, Age {height. 1} {2}"
V = test.format ( 'Tom', 19,182)
Print (V)

# third
# formatted incoming values { "name" : 'Alex', "A":}. 19
Test = "I AM {name}, Age {A}"
V = test.format_map ({ "name": 'Alex', "A":}. 19)
Print (V )


# ==================== ten ==========================

# determining whether the character string contains only alphanumeric
Test = "user789_ +"
V = test.isalnum ()
Print (V)

Guess you like

Origin www.cnblogs.com/pythonzhao/p/11710827.html