计算机网络/计算机科学与应用/系统/运维/开发

Python 字符串

# 字符串
# 定义字符串的三种方式
s1 = "Hello"
s2 = 'Python'


# 定义字符串
msg3 = "hello 意见是 \"你好\""
print(msg3)


# 字符串拼接  +
slogan = "hello" + "world"
print(slogan)
s1 = "python"
print("nihao: " + s1)


# str(int数字) 将int类的数字转为字符串
age = 18
print(str(age))
print(type(str(age)))


# 字符串格式化 %
s5 = "涛哥"
print("大家伙,我是 %s" % s5)


若无人替你披荆斩棘,那就独自前行栉风沐雨。

评论

^