In [1]:
class Point:
    '''2차원 공간에 점을 표현한다.'''

In [2]:
Point


Out[2]:
__main__.Point

In [4]:
print(Point)


<class '__main__.Point'>

In [5]:
blank = Point()

In [6]:
print(blank)


<__main__.Point object at 0x10406add8>

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)


3.0 4.0

In [11]:
import copy

In [12]:
p2 = copy.copy(p1)

In [13]:
print(p2.x,p2.y)


3.0 4.0

In [14]:
p1.x = 100

In [15]:
print(p1.x, p2.x)


100 3.0

In [16]:
p1 == p2


Out[16]:
False

In [17]:
p1 is p2


Out[17]:
False

In [22]:
fout = open('output.txt','w')

In [23]:
line1 = 'This is book\n'
fout.write(line1)


Out[23]:
13

In [24]:
line2 = 'the game\n'
fout.write(line2)


Out[24]:
9

In [25]:
fout.close()

In [26]:
print("%f " % 5.5)


5.500000 

In [27]:
print("%g" % 5.5)


5.5

In [29]:
print("{}".format(5.5))


5.5

In [30]:
import os

In [31]:
cwd = os.getcwd()

In [32]:
print(cwd)


/Users/jaegyuhan/PythonEx_1/토요_파이썬

In [33]:
os.path.abspath('output.txt')


Out[33]:
'/Users/jaegyuhan/PythonEx_1/토요_파이썬/output.txt'

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]:
b'Photo of John Cleese.'

In [38]:
db.close()

In [39]:
import pickle

In [40]:
t = [1,2,3]

In [41]:
pickle.dumps(t)


Out[41]:
b'\x80\x03]q\x00(K\x01K\x02K\x03e.'

In [42]:
with os.popen('ls -al') as fp:
    print(fp.read())


total 536
drwxr-xr-x   18 jaegyuhan  staff    612 12 16 00:46 .
drwxr-xr-x  423 jaegyuhan  staff  14382 12 14 18:17 ..
drwxr-xr-x   14 jaegyuhan  staff    476 12 15 10:48 .ipynb_checkpoints
-rw-r--r--    1 jaegyuhan  staff  40082 12  9 11:53 11에서 12장.ipynb
-rw-r--r--    1 jaegyuhan  staff   9047 12 16 00:46 15장.ipynb
-rw-r--r--    1 jaegyuhan  staff  53968 12  2 10:27 5장 6장.ipynb
-rw-r--r--    1 jaegyuhan  staff  13464 12  2 11:39 7에서10장.ipynb
-rw-r--r--    1 jaegyuhan  staff  16384 12 16 00:43 captions.db
-rw-r--r--    1 jaegyuhan  staff   6671 11 22 09:55 code_inter1.ipynb
-rw-r--r--    1 jaegyuhan  staff     22 12 15 15:00 output.txt
-rw-r--r--    1 jaegyuhan  staff     52 11 22 14:35 test.py
-rw-r--r--    1 jaegyuhan  staff  24016 12 13 16:18 이터 제너레이션.ipynb
-rw-r--r--    1 jaegyuhan  staff   4008 11 22 00:08 퀵소트 구현 .ipynb
-rw-r--r--    1 jaegyuhan  staff  49165 11 18 18:41 클로저 연습.ipynb
-rw-r--r--    1 jaegyuhan  staff   5980 12  2 10:20 함수형 파이썬.ipynb
-rw-r--r--    1 jaegyuhan  staff  10564 11 11 18:05 텐서플로우 기본 연습.ipynb
-rw-r--r--    1 jaegyuhan  staff   4094 11 21 13:14 삽입정렬 구현.ipynb
-rw-r--r--    1 jaegyuhan  staff   5419 11 21 15:02 선택정렬 구현.ipynb


In [43]:
13/2


Out[43]:
6.5

In [44]:
round(6.5)


Out[44]:
6

In [45]:
11/2


Out[45]:
5.5

In [46]:
round(5.5)


Out[46]:
6

In [50]:
os.listdir('/Users/jaegyuhan/PythonEx_1/토요_파이썬/output.txt')


---------------------------------------------------------------------------
NotADirectoryError                        Traceback (most recent call last)
<ipython-input-50-7e71ab5f31eb> in <module>()
----> 1 os.listdir('/Users/jaegyuhan/PythonEx_1/토요_파이썬/output.txt')

NotADirectoryError: [Errno 20] Not a directory: '/Users/jaegyuhan/PythonEx_1/토요_파이썬/output.txt'

In [ ]: