书中面向过程部分的笔记
- 章节名:书中面向过程部分的笔记
- 指数:3**5 表示 3^5 - 类型转换: float() int()#下取整 int(a+0.5)#四舍五入 str() - 告诉变量类型:type() - 输入: somename = raw_input()#输入为字符串 somename = raw_input("Enter your name")#打印提示语 输入浮点数:f=float(raw_input()) - 逗号','表示打印完这个内容后不要跳转到下一行(自动加空格) - 使用 Easygui 模块:import easygui easygui.msgbox("Hello World") - 判断: if a == b: whatwhat... elif ...: whatwhat... else ...: whatwhat... 直接用 and or not(如:not(age<8)) - 循环: for looper in [1,2,3,4,5]:#CTRL+C 终止程序 print "hello" for looper in range(1,5):#前闭后开,range(5) 与 range(0,5) 一样 ... range(1,10,2)#第三个是步长,可正可负 while ...: ... 可用 continue break - import time time.sleep(1)#等待一秒 - 注:本书中的输出是 Python 2.x 的形式 3.x 去除 print 语句,加入 print() 函数实现相同的功能 3.x 输入函数改变,删除了 raw_input,用 input 代替 其它变化详见:http://www.cnblogs.com/codingmylife/archive/2010/06/06/1752807.html -
说明 · · · · · ·
表示其中内容是对原文的摘抄