-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_abc.py
More file actions
80 lines (64 loc) · 1.59 KB
/
Copy pathquick_abc.py
File metadata and controls
80 lines (64 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /usr/bin/python
# 中文
import py_compile
import global_var
import sys
def hello_world():
print ("hello word") # 发放
def test_compile():
py_compile.compile('./quick_abc.py')
def test_id():
x = 1
print (id(x))
print ('----')
x = 2
print (id(x))
def fun():
print (global_var._a)
print (global_var._b)
# class _const:
# class ConstError(TypeError): pass
# def __setattr__(self,name,vlaue):
# if self.__dict__.has_key(name):
# raise self.ConstError('Can’t rebind const(%s)'%name)
# self.__dict__[name]=value
# sys.modules[__name__] = _const()
def test_tuple():
tuple_name=('apple','banana','grape','orange')
for element in tuple_name:
print(element)
def test_list():
list=['apples','bananas','grapes','oranges']
list.append('grapes')
try:
list.remove('banana')
except:
print('something wrong')
for element in list:
print(element)
def test_dict():
dict={'a':'apple','b':'banana','g':'grape'}
for element in dict:
print(element)
for element in dict.values():
print(element)
def test_str():
word='world'
print (word[0:3])
def test_file():
context='hello, world'
filename='hello.txt'
with open(filename, "wb") as file:
file.write(context)
file.close()
class Fruit:
def grow(self):
print('Fruit grow')
class Apple(Fruit):
def test(self):
print(Fruit.grow(Fruit))
if __name__ == '__main__':
Apple.test(Apple)
# Fruit.grow(Fruit)
# fruit=Fruit()
# fruit.grow()