字符串可以通过以下几种方式进行赋值:
s = "Hello, world!"
s1 = "Hello"
s2 = "world!"
s = s1 + ", " + s2
s1 = "Hello"
s = s1 * 3 # 将字符串"Hello"重复3次
name = "Alice"
age = 25
s = "My name is {} and I am {} years old.".format(name, age)
name = "Alice"
age = 25
s = f"My name is {name} and I am {age} years old."
无论使用哪种方式,都可以通过赋值运算符将字符串赋值给变量。