#字符串输出
a="Hello"
b="Pyhton"
print(a+b)
print(a*2)
print(a[1])
print(a[1:4])
#换行输出
print("离离原上草,\n一岁一枯荣.")
#输出十二星座
for i in range(12):
print(chr(9800+i),end="")
#格式化输出
print("I', %s.I'm %d year old"%('Lucy',20))
a=15
b=12345678.1234567
strs="I love Python!"
print("a=%05d"%a)
print("b=%8.3f"%b)
print("%17s"%strs)
print("%17r"%strs)
print("%-17.5s"%strs)
#字符串切片操作
str1="hello,python!hello,c!"
print(str1[6:12])
print(str1[-8:-1])
print(str1[:-3])
print('java' in str1)
print('python' in str1)
#进制转换
num=int(input("请输入一个自然数"))
print("二进制",bin(num))
print("八进制",oct(num))
print("十六进制",hex(num))
10-13
1096
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-29
845
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-21
7万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)