字符串、数字等基本数据类型
1 #!/usr/bin/env python 3 2 # -*- coding:utf-8 -*- 3 4 #1、字符串(以前后引号引起来的内容为字符串) 5 # A 字符串的基本形式 6 ''' 7 name = 'abc' 8 name = "abc" 9 name = '''abc''' 10 ''' 11 # B 字符串的加法 12 ''' 13 n1 = 'abc' 14 b2 = 'de' 15 b3 = 'fg' 16 n4 = n1 + n2 +n3 17 则n4 = 'abcdefg' 18 ''' 19 # C 字符串的乘法 20 ''' 21 n1 = 'abc' 22 n2 = n1 * 3 23 则n2 = 'abcabcabc' 24 '' 25 ''' 26 27 #2、数字 28 #同理数字支持+ - * / ** // % 等数字运算 29 ''' 30 a = 10 31 b = 2 32 c = a - b = 8 33 d = a*b = 20 34 e = a/b = 4.0 35 f = a//b = 4(地板除,取整或者说取商) 36 g = a ** b = 10 ^ 2 = 100(幂次运算) 37 h = a % b = 0(取余数)