python 入门语法

来源:互联网 发布:广州动易软件 编辑:程序博客网 时间:2024/05/21 09:28
1.简单的循环
while count >0print count, # 有逗号被程序表示做空格,且不换行count-=1while count < 10print count  count +=1
output:

10 9 8 7 6 5 4 3 2 1 0
1
2
3
4
5
6
7
8
9
Press any key to continue . . .
2.命令行读写文件

>>> f = open("test.py")>>> f.read() // read() 方法是默认读取所有,readline() 就是读一行'\xef\xbb\xbffor each in [1,223,3,4,4,4,5,5,534,67]:\n\tprint each'>>> f.close()