1. 程式人生 > >Python (3): 小常識

Python (3): 小常識

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)