# coding:utf-8print'int type : %s' % 1print'float type : %s' % 1.1print'String type : %s' % 'OK'print'boolean type : %s' % Trueprint'and : %s' % TrueandFalseprint'or type : %s' % TrueorFalseprint'none type : %s' % Noneprint'ord type : %s' % ord('A')
print'chr type : %s' % chr(65)
printu'中文'.encode('utf-8')
print'length %s' % len(u'ABC')
print'\xe4\xb8\xad\xe6\x96\x87'.decode('utf-8')
List的用法
# coding:utf-8
list = ['A', 'B', 'C']
print'LIST : %s' % list
print'LENGTH : %s ' % len(list)
print'[0] : %s' % list[0]
list.append('D')
print'append LIST : %s' % list
list.pop(1)
print'pop LIST : %s' % list
L = ['Apple', 123, True]
print'不同的数据类型:%s ' % L
p = ['asp', 'php']
s = ['python', 'java', p, 'scheme']
print'嵌套LIST : %s 长度:%s' % (s, len(s))
条件判断循环
# coding:utf-8
age = 19if age <= 18:
print'少年'
elif age < 20:
print'壮年'else:
print'成年'list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in list:
print'当前值:%s' % i