标签:中括号 tin foreach 代码 没有 语法 abc 引号 logs
>>> print("""\
a
b
c\
""")
a
b
c
>>> 'a' * 3
'aaa'
>>> 'b' 'a'
'ba'
>>> 'b' + "a"
'ba'
>>> "abcde"[1:]
'bcde'
>>> "abcde"[:4]
'abcd'
>>> "abcde"[:]
'abcde'
>>> "abcde"[-3:]
'cde'
>>> [1,2,3][1:]
[2, 3]
>>> [1,2,3][-2:]
[2, 3]
>>> a = [1,2,3,4]
>>> a[2:] = [4,5,6]
>>> a
[1, 2, 4, 5, 6]
>>> a[2:] = []
>>> a
[1, 2]
>>> for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
print(n, 'is a prime number')
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
标签:中括号 tin foreach 代码 没有 语法 abc 引号 logs
原文地址:http://www.cnblogs.com/zwvista/p/7965931.html