Python (3): 小常识

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tonywang1945yes/article/details/79448930

1,Python 没有自增运算符
2,字符串用+连接,用[]分割
x="hello,world"
x=x[:2]+'python'+x[2:]
print(x)


3, 逻辑运算如下,注意True False 大写

x=True
y=False
print(x or y)
print (x and y)
print(not x)

4,string 转 int

c=input()
if c.isdigit():
    print(int(c)+1)

猜你喜欢

转载自blog.csdn.net/tonywang1945yes/article/details/79448930
今日推荐