1.字符串 单双引号,多行字符用三引号
2.字符串链接可以用“+”号
3.数字自增运算符用+=,自减-=
4.科学计算,3.8e16,3.8e-13
5.3**5 3的五次方
6.数据类型,str(),float(),int()强制转换,type()可获取变量类型
7.输入:raw_input
print “Enter your name: ”
somebody=raw_input()
print "hi",somebody,"how are you today"
逗号,会把 字符串链接到一起,
print “My”,
print "name",
print "is",
print "Dave"
结果为: My name is Dave.
8.从互联网读取文件
import urllib
file=urllib.urlopen("http://www.aa.bb.com/message.txt")
message=file.read();
print message
9.条件判断
if answer >=10:
print .....
elif answer >=5:
print ....
else:
print "you got ..."
或者:
if age >=8:
print "you got "
else:
print "sorry"
9. 条件中的and 相当于&
if age >=8 and grade >=3:
print "you can play this game"
else:
print "sorry"
10.or 或条件