What I learned today is Python The content is a string :
Case code :
# character string :Python Single character type... Is not supported , A single character is also a string
# String encoding :Python3 The default character is 16 position Unicode code
# Use built-in functions ord() Can convert characters to corresponding Unicode code
# Use built-in functions char() You can convert decimal numbers into corresponding characters
# The result of printing is 65
print(ord('A'))
# The result of printing is 39640
print(ord(' high '))
# The result of printing is B
print(chr(66))
# Create string
a = " test "
# Print test
print(a)
# An empty string and len() function
#Python Allow the existence of empty strings
#len() Used to calculate how many characters a string contains
# The result of printing is 2
print(len(a))
# Escape character
# \( When at the tail ) Endurance
# \\ Backslash notation
# \' Single quotation marks
# \“ Double quotes
# \b Backspace
# \n Line break
# \t Horizontal tabs
# \r enter
a = "i\nam\n test "
# Print the results by :
# i
#am
# test
print(a)
# String copy
a = "sex"*4
# Print the results :sexsexsexsex
print(a)
# Print without wrapping call print Will automatically print a line break
# Print without line breaks end
# Print the results :23123
print(23, end="")
print(123)
# The console gets the string
# Input a Print a
myname = input(" Please enter your name :")
print(" Your name is :"+myname)
#str() Realize digital transformation string
a = 123
print(str(a))
# Use [] Extract characters
b = "123"
# The result is 2
print(b[1])
#replace() Implement string substitution
# The string cannot be changed . however , We really need to replace characters , At this time , We can only do this by creating new strings
# The result of printing is : 1 Shirley 3
print(b.replace('2', ' Shirley '))
That's all for my sharing ! Let's learn together !
2021 year 3 month Python Analy