1. 编译型语言和解释型的区别:以书的翻译为例,编译型语言就是翻译一次性把书翻译好了,然后给你看;解释型语言就是你看一句,翻译一句的这种;
2. shell脚本第一行的作用是,给系统说明解释器;
#!/usr/bin/enf python
3.变量作用:保存,方便后面使用;可以使用数字,字母,下划线进行定义;
!%s保存字符型,input读取的内容都是字符,如果后面是整型调用,那么需要使用强制转换;
!‘’‘’‘’注释符的作用,还可以用来保存一段文字;
4.三种输出模式:
!(1)使用拼接,如果很长的话不建议;
! (2)使用占位符,例如%s等,对应输出;
info = "My name is %s, and age is %d",%(name,age)
! (3) 使用format进行输出;
info = "My name is {_name},and age is {_age}".format(_name=name,_age=age);
!(4) 使用对应顺序;一一对应,上一种功能模式顺序可以调换;
info = "My name is {0},and age is {1}".format(name,age)
5.for/while:循环;
# _age = 25 # age = int(input("age:")) # if age == _age : # print("You got it! ") # elif age > _age: # print("Think smaller") # else: # print("Think bigger!") # _age = 25 # count = 0 # while count < 3: # age = int(input("age:")) # if age == _age: # print("You got it! ") # break # elif age > _age: # print("Think smaller") # else: # print("Think bigger!") # count += 1 # if count == 3: # cont_or_not = input("Do you want to continue or not?") # if cont_or_not != 'N': # count = 0 # else: # break for i in range(0,10,3): print(i)