Python 学习 字符串等等

我的未来我决定 提交于 2020-01-14 09:03:24

快捷键
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")

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!