1 Python里面的数据类型 interage , floats , booleans , String等
2 Python是一个区分大小写的语言
3 Python的变量可以随时进行覆盖
把变量fifth_letter设置为MONTY的第五个字符
fifth_letter = "MONTY"[4]
print fifth_letter
parrot = "Norwegian Blue"
print len(parrot)
parrot = "Norwegian Blue"
print parrot.lower()
把parrot中的小写字母转换为大写字母并打印
parrot = "norwegian blue"
print parrot.upper()
设置一个变量pi值为3.14 , 把pi转化为字符串
pi = 3.14
print str(pi)
print "The value of pi is around " + str(3.14)
---- Date and Time
设置变量now的值为 datetime.now()
from datetime import datetime
now = datetime.now()
print now # 打印now的值
从datetime.now中得到的信息中提取出year,month,day
from datetime import datetime
now = datetime.now()
print now.month
print now.day
print now.year
15 介绍把输出日期的格式转化为mm//dd//yyyy,我们利用的是+来转化
打印当前的日期的格式为mm//dd//yyyy
from datetime import datetime
now = datetime.now()
print str(now.month)+"/"+str(now.day)+"/"+str(now.year)
打印当前的时间的格式为hh:mm:ss
from datetime import datetime
now = datetime.now()
print str(now.hour)+":"+str(now.minute)+":"+str(now.second)
把日期和时间两个连接起来输出
print str(now.month) + "/" + str(now.day) + "/" + str(now.year) + " "\
+str(now.hour) + ":" + str(now.minute) + ":" + str(now.second)
转载于:https://www.cnblogs.com/sun9/p/8267252.html