Python语法基础
1.字符串之间可以进行加法运算
实际是把字符串拼接起来
例:
str1='hello' str2='word' str3=str1+str2 print(str3)
输出结果:
helloword
2.字符串和数字之间可以进行乘法运算
实际是复制2(num)个字符串(str1)
str1='hello' num=2
x=str1*num
print(x)
输出:
hellohello
1.字符串之间可以进行加法运算
实际是把字符串拼接起来
例:
str1='hello' str2='word' str3=str1+str2 print(str3)
输出结果:
helloword
2.字符串和数字之间可以进行乘法运算
实际是复制2(num)个字符串(str1)
str1='hello' num=2
x=str1*num
print(x)
输出:
hellohello