s = set(['Adam', 'Lisa', 'Paul'])
L = ['Adam', 'Lisa', 'Bart', 'Paul']
t = set(L)
for a in s:
t.remove(a)
print t
L = ['Adam', 'Lisa', 'Bart', 'Paul']
t = set(L)
for a in s:
t.remove(a)
print t
2015-08-02
注意: Python代码的缩进规则。具有相同缩进的代码被视为代码块,上面的3,4行 print 语句就构成一个代码块(但不包括第5行的print)。如果 if 语句判断为 True,就会执行这个代码块。
缩进请严格按照Python的习惯写法:4个空格,不要使用Tab,更不要混合Tab和空格,否则很容易造成因为缩进引起的语法错误。
注意: if 语句后接表达式,然后用:表示代码块开始
缩进请严格按照Python的习惯写法:4个空格,不要使用Tab,更不要混合Tab和空格,否则很容易造成因为缩进引起的语法错误。
注意: if 语句后接表达式,然后用:表示代码块开始
2015-08-02
s = 'Python was started in 1989 by \"Guido\".'
print s
s = "Python is free and easy to learn."
print s
s = "Python was started in 1989 by \"Guido\"."
print s
print s
s = "Python is free and easy to learn."
print s
s = "Python was started in 1989 by \"Guido\"."
print s
2015-08-02
#input code
print("hello,python");
print 'hello,''python';
print("hello,python");
print 'hello,''python';
2015-08-02
print L[0]
print L[1]
print L[2]
print L[2]或者
print L[0]
print L[0]
print L[1]
print L[2]
print L[1]
print L[2]
print L[2]或者
print L[0]
print L[0]
print L[1]
print L[2]
2015-08-01
L.pop(3)
L.pop(2)
print L或
L.pop(2)
L.pop(2)
print L
L.pop(2)
print L或
L.pop(2)
L.pop(2)
print L
2015-07-31
L = ['Adam', 'Lisa', 'Bart']
L.insert(2,'Paul')或
L.insert(-2,'Paul')
print L
L.insert(2,'Paul')或
L.insert(-2,'Paul')
print L
2015-07-31
L = [95.5, 85, 59]
print L[-1]
print L[-2]
print L[-3]
print L[-4]
这样也能过
print L[-1]
print L[-2]
print L[-3]
print L[-4]
这样也能过
2015-07-31
L = [95.5,85,59]
print L[0]
print L[0]
print L[1]
print L[2]
print L[0]
print L[0]
print L[1]
print L[2]
2015-07-31
L = ['Adam',95.5,'Lisa',85,'Bart',59]
print L
print L
2015-07-31
L=[]
for a in '123456789':
for b in '0123456789':
for c in '123456789':
if a==c:
L.append(a+b+c)
print L
for a in '123456789':
for b in '0123456789':
for c in '123456789':
if a==c:
L.append(a+b+c)
print L
2015-07-31
isinstance(object,class-or-type-or-tuple)->bool
Return whether an object is an instance of a class or of a subclass thereof.
With a type as second argument,return whether that is the object's type
The form using a tuple,isinstance(x,(A,B,...)),is a shortcut for
isinstance(x,A) or isinstance(x,B) or.
Return whether an object is an instance of a class or of a subclass thereof.
With a type as second argument,return whether that is the object's type
The form using a tuple,isinstance(x,(A,B,...)),is a shortcut for
isinstance(x,A) or isinstance(x,B) or.
def firstCharUpper(s):
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s[0].upper()+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-07-31