Python中字符串的創建方法有以下幾種:
str1 = 'Hello World'
str2 = "Python is awesome"
str3 = '''This is a
multi-line string'''
str4 = 'I\'m a programmer'
str5 = "He said, \"Hello World\""
str6 = r'C:\Users\Username\Desktop'
name = 'Alice'
age = 25
str7 = 'My name is {} and I am {} years old'.format(name, age)
str8 = 'Hello' + ' ' + 'World'
str9 = 'Python' * 3
需要注意的是,字符串是不可變的,即不能對字符串進行修改,但可以通過創建新的字符串來實現對字符串的修改。