In [1]:
class Point:
'''2차원 공간에 점을 표현한다.'''
In [2]:
Point
Out[2]:
In [4]:
print(Point)
In [5]:
blank = Point()
In [6]:
print(blank)
In [7]:
class Rectangle:
width = 100.0
height = 200.0
In [8]:
p1 = Point()
p1.x = 3.0
p1.y = 4.0
In [10]:
print(p1.x, p1.y)
In [11]:
import copy
In [12]:
p2 = copy.copy(p1)
In [13]:
print(p2.x,p2.y)
In [14]:
p1.x = 100
In [15]:
print(p1.x, p2.x)
In [16]:
p1 == p2
Out[16]:
In [17]:
p1 is p2
Out[17]:
In [22]:
fout = open('output.txt','w')
In [23]:
line1 = 'This is book\n'
fout.write(line1)
Out[23]:
In [24]:
line2 = 'the game\n'
fout.write(line2)
Out[24]:
In [25]:
fout.close()
In [26]:
print("%f " % 5.5)
In [27]:
print("%g" % 5.5)
In [29]:
print("{}".format(5.5))
In [30]:
import os
In [31]:
cwd = os.getcwd()
In [32]:
print(cwd)
In [33]:
os.path.abspath('output.txt')
Out[33]:
In [34]:
import dbm
In [35]:
db = dbm.open('captions','c')
In [36]:
db['cleese.png'] = 'Photo of John Cleese.'
In [37]:
db['cleese.png']
Out[37]:
In [38]:
db.close()
In [39]:
import pickle
In [40]:
t = [1,2,3]
In [41]:
pickle.dumps(t)
Out[41]:
In [42]:
with os.popen('ls -al') as fp:
print(fp.read())
In [43]:
13/2
Out[43]:
In [44]:
round(6.5)
Out[44]:
In [45]:
11/2
Out[45]:
In [46]:
round(5.5)
Out[46]:
In [50]:
os.listdir('/Users/jaegyuhan/PythonEx_1/토요_파이썬/output.txt')
In [ ]: