python学习记录1

之前也学过其他一些编程语言,感觉跟python相比真的很不一样
python语法有很多独特的地方,比起其他语言要简洁不少,也方便很多。

python是动态语言,使用变量时不需要定义类型,可以直接赋值
例如

a = 10
b = 'a'
c = "hello world"

也不需要在结尾加上分号

输入输出大同小异

temp=input()
print(temp)

定义函数

def fuzhi():
    return 5
a=fuzhi()
print(a)

python不需要花括号,取而代之的是在后边加一个冒号 if,else,while等同理
在python中缩进具有重要意义,必须要注意

利用Type()函数可以得到变量类型
例如print(Type(True))可以返回bool

猜你喜欢

转载自blog.csdn.net/qq_38929220/article/details/82054446
今日推荐