1 Star 0 Fork 0

niushijin24 / pythonzero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test10.py 772 Bytes
一键复制 编辑 原始数据 按行查看 历史
niu.sj 提交于 2024-05-19 07:41 . add comment
#单引号与双引号
print( 'hell "python"' ) #hell "python"
print( "hell 'python'" ) #hell 'python'
print( "hell \"python\"" ) #hell "python"
print( 'hell \'python\'' ) #hell 'python'
#三引号 空行也会输出
print('''
hello
ok
''')
print("====")
print("""
hello
ok
""")
#字符串中使用变量
x=123
print("x=", x) #x= 123
print(f"x={x}") #x=123 嵌入值
print(f"{x} {x} twice") #123 123 twice
y=456
print(f"{x} {y} two numbers") #123 456 two numbers
#字符基本操作
print("x" in "x123") #True
print("x" not in "x123") #False
print("abc"+"def") #abcdef
print("abc"*3) #abcabcabc
#切片
print("abcdef"[3]) #d
print("abcdef"[-1]) #f
print("abcdef"[1:4]) #bc
print("abcdef"[1:]) #bcdef
print("abcdef"[1:5:2]) #bd 从1到5,步长为2
1
https://gitee.com/niushijin24/pythonzero.git
git@gitee.com:niushijin24/pythonzero.git
niushijin24
pythonzero
pythonzero
master

搜索帮助