Python 学习 字符串等等

快捷键
alt+P 上一句命令

引号之用

 print('"life is short ,I need Python"')

结果
“life is short ,I need Python”

print ("Let's go!")

结果
Let’s go!

print (''' "Let's go!" ''')

结果
“Let’s go!”

print ('Let\'s go!\nBaby')

结果
Let’s go!
Baby

原始字符串

字符串前加上个 r
各种转义字符不受影响

print(r"\\\fsuidagfudsig\n \r\t")
三个引号(三个单引号或者双引号)

不用加换行

poetry ="""



oh
      oh

             oh


                  ok






"""

结果
在这里插入图片描述

字符串 的 加 乘

在这里插入图片描述

print("hankai\
	  HANKAI")

加 \ 可以换行( 在" "里面)

发布了35 篇原创文章 · 获赞 2 · 访问量 919

猜你喜欢

转载自blog.csdn.net/hk2121/article/details/103934603
今日推荐