One: Basic use
str purposes: descriptive data, such as name \ nationality \ education \ home address
It is defined by: a string of characters in a single or double quotation marks or a three
= name 'Egon' name = # STR ( 'Egon')
# master:
# str(10) #int('10')
# Knowledge of
# True = p (10)
# True = p ([1,2,3,4])
# print(res,type(res))
# int('10')
# res=float('10.3')
# print(res,type(res))
# + Common operations built-in method
The priority control operation #:
# 1, according to the index value (Forward + Reverse take take): only take
name = 'egon Hello'
# print(name[0])
# print(name[4])
# print(name[1000])
# print(name[-1])
# print(type(name[-2]))
# Name [-1] = 'bad'
# 2, a slice (care regardless of the end, step)
# msg='alex say my name is sb'
# print(msg[0:6])
# print(msg[0:6:2]) #alex s
# ae
#To understanding:
# print(msg[0:5:1])
# print(msg[3:1:-1])
# print(msg[-1:-5:-1])
# msg='alex is sb'
# print(msg[0:10:1])
# print(msg[:])
# print(msg[::1])
# print(msg[::-1])
# 3, the length len
# msg='alex say my name is sb'
# Print the number (len (msg)) # characters
# 4, members of the operations in and not in
# msg='alex say my name is sb'
# print('alex' in msg)
# print('alex' not in msg)
# 5, remove the blank strip
#S = '***** egon ****'
# print(s.strip('*'))
# s=s.strip('*')
# print(s)
# name=' egon '
# print(name.strip())
# Improve
# Name = input ( 'User name >>:') .strip ()
# Print (len (name))
# name=name.strip()
# if name == 'alex':
# Print ( 'user name correct')
# 6, slicing split
# Info = 'egon: 123: admin'
# Res = info.split ( ':')
# print(res,type(res))
# print(res[0])
#
# cmd='get|a.txt|32123123'
# print(cmd.split('|'))
# 7, cycling
# msg='alex'
# i=0
# while True:
# if i < len(msg):
# print(msg[i])
# i+=1
# else:
# break
# msg='alex'
#
# i=0
# while True:
# if i == len(msg):
# break
# print(msg[i])
# i+=1
# msg='alex'
#
# i=0
# while i < len(msg):
# print(msg[i])
# i+=1
msg='alex'
for item in msg: #item='l'
print(item)
# For item in 11111: # only strings, lists, dictionaries
# print(item)
# # II: The Type Summary
# Stored value or a plurality of stored values
# Can store a value
# Can store multiple values, values are what type
# Ordered or unordered
# Variable or immutable
#! ! ! Variable: value change, id unchanged. Variable == not hash
#! ! ! Immutable: variable value, id becomes. == hash be immutable