84 字
约 16 秒
8
创建字符串
2026-09-26
无标签
创建字符串
s1 = 'hello'
print(s1)
s2 = "hello"
print(s2)
s3 = '''2024
hello
world'''
print(s3)
s4 = "it's a hat"
print(s4)
s5 = '1234'"666'
print(s5)
字符串的拼接
print('**************')
print(s1 + s3 + s5)
n = 5
print(s1 + n) # 字符串与数字不能相加
字符串的乘法
print('-----字符串的乘法-------')
print(s1 * 2)
print('*' * 20)
print(3 * 'happy')
评论
0 条
还没有评论,先写一条吧。