티스토리 뷰

2019.02.08-1

chr() 함수와 ord() 함수

In [1]:
ord('a')   # 기본적인 문자를 0~255번 사이에 지정해 놓았다.
Out[1]:
97
In [3]:
chr(97)   # ord() 함수와 반대이다.
Out[3]:
'a'
In [4]:
chr(98)
Out[4]:
'b'
In [13]:
for i in range(26):  # a부터 z까지 출력하고자 할 때 
    print(chr(ord('a')+i)) 
    
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

enumerate

In [11]:
l=[5,4,1,3,2] 
for (i,n) in enumerate(l): #내가 원하는 값이 몇번째인지 알고 싶을 때
    print(i,n)
0 5
1 4
2 1
3 3
4 2

round (반올림)

In [15]:
round(1.6)
Out[15]:
2
In [16]:
round(1.2)
Out[16]:
1

zip

In [20]:
zip([1,2,3],['a','b','c'])  # 어떤 두 쌍을 큐플로 묶어준다.
Out[20]:
<zip at 0xbb99fae4c8>
In [21]:
list(_)       # '_'는 방금전에 실행했던 명령어
Out[21]:
[(1, 'a'), (2, 'b'), (3, 'c')]
In [22]:
name=['홍','장','박']
age=[35,47, 27]
for (i,j) in zip(name,age):
    print(i,j)
홍 35
장 47
박 27
In [31]:
name=['홍','장','박']
age=[35,47, 27]
for i,(j,k) in enumerate(zip(name,age)):
    print(i,j,k)
0 홍 35
1 장 47
2 박 27

모듈

In [32]:
import math
In [33]:
math.log(100)
Out[33]:
4.605170185988092
In [34]:
math.log10(100)
Out[34]:
2.0
In [35]:
dir(math) # 함수 목록
Out[35]:
['__doc__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 'acos',
 'acosh',
 'asin',
 'asinh',
 'atan',
 'atan2',
 'atanh',
 'ceil',
 'copysign',
 'cos',
 'cosh',
 'degrees',
 'e',
 'erf',
 'erfc',
 'exp',
 'expm1',
 'fabs',
 'factorial',
 'floor',
 'fmod',
 'frexp',
 'fsum',
 'gamma',
 'gcd',
 'hypot',
 'inf',
 'isclose',
 'isfinite',
 'isinf',
 'isnan',
 'ldexp',
 'lgamma',
 'log',
 'log10',
 'log1p',
 'log2',
 'modf',
 'nan',
 'pi',
 'pow',
 'radians',
 'sin',
 'sinh',
 'sqrt',
 'tan',
 'tanh',
 'tau',
 'trunc']
In [37]:
help(math.sin) #help 자주 사용하기
Help on built-in function sin in module math:

sin(...)
    sin(x)
    
    Return the sine of x (measured in radians).

In [38]:
import os
In [39]:
dir(os)
Out[39]:
['DirEntry',
 'F_OK',
 'MutableMapping',
 'O_APPEND',
 'O_BINARY',
 'O_CREAT',
 'O_EXCL',
 'O_NOINHERIT',
 'O_RANDOM',
 'O_RDONLY',
 'O_RDWR',
 'O_SEQUENTIAL',
 'O_SHORT_LIVED',
 'O_TEMPORARY',
 'O_TEXT',
 'O_TRUNC',
 'O_WRONLY',
 'P_DETACH',
 'P_NOWAIT',
 'P_NOWAITO',
 'P_OVERLAY',
 'P_WAIT',
 'PathLike',
 'R_OK',
 'SEEK_CUR',
 'SEEK_END',
 'SEEK_SET',
 'TMP_MAX',
 'W_OK',
 'X_OK',
 '_Environ',
 '__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '_execvpe',
 '_exists',
 '_exit',
 '_fspath',
 '_get_exports_list',
 '_putenv',
 '_unsetenv',
 '_wrap_close',
 'abc',
 'abort',
 'access',
 'altsep',
 'chdir',
 'chmod',
 'close',
 'closerange',
 'cpu_count',
 'curdir',
 'defpath',
 'device_encoding',
 'devnull',
 'dup',
 'dup2',
 'environ',
 'errno',
 'error',
 'execl',
 'execle',
 'execlp',
 'execlpe',
 'execv',
 'execve',
 'execvp',
 'execvpe',
 'extsep',
 'fdopen',
 'fsdecode',
 'fsencode',
 'fspath',
 'fstat',
 'fsync',
 'ftruncate',
 'get_exec_path',
 'get_handle_inheritable',
 'get_inheritable',
 'get_terminal_size',
 'getcwd',
 'getcwdb',
 'getenv',
 'getlogin',
 'getpid',
 'getppid',
 'isatty',
 'kill',
 'linesep',
 'link',
 'listdir',
 'lseek',
 'lstat',
 'makedirs',
 'mkdir',
 'name',
 'open',
 'pardir',
 'path',
 'pathsep',
 'pipe',
 'popen',
 'putenv',
 'read',
 'readlink',
 'remove',
 'removedirs',
 'rename',
 'renames',
 'replace',
 'rmdir',
 'scandir',
 'sep',
 'set_handle_inheritable',
 'set_inheritable',
 'spawnl',
 'spawnle',
 'spawnv',
 'spawnve',
 'st',
 'startfile',
 'stat',
 'stat_float_times',
 'stat_result',
 'statvfs_result',
 'strerror',
 'supports_bytes_environ',
 'supports_dir_fd',
 'supports_effective_ids',
 'supports_fd',
 'supports_follow_symlinks',
 'symlink',
 'sys',
 'system',
 'terminal_size',
 'times',
 'times_result',
 'truncate',
 'umask',
 'uname_result',
 'unlink',
 'urandom',
 'utime',
 'waitpid',
 'walk',
 'write']
In [40]:
os.listdir()
Out[40]:
['.anaconda',
 '.conda',
 '.idlerc',
 '.ipynb_checkpoints',
 '.ipython',
 '.jupyter',
 '.matplotlib',
 '.spyder-py3',
 '.swt',
 '2019.02.07.조환희.ipynb',
 '2019.1.31 조환희.ipynb',
 'Anaconda3',
 'AppData',
 'Application Data',
 'Contacts',
 'Cookies',
 'Desktop',
 'Documents',
 'Downloads',
 'Favorites',
 'IntelGraphicsProfiles',
 'iris.csv',
 'Jfun',
 'Links',
 'Local Settings',
 'Music',
 'My Documents',
 'NetHood',
 'NTUSER.DAT',
 'ntuser.dat.LOG1',
 'ntuser.dat.LOG2',
 'NTUSER.DAT{bbed3e3b-0b41-11e3-8249-d6927d06400b}.TM.blf',
 'NTUSER.DAT{bbed3e3b-0b41-11e3-8249-d6927d06400b}.TMContainer00000000000000000001.regtrans-ms',
 'NTUSER.DAT{bbed3e3b-0b41-11e3-8249-d6927d06400b}.TMContainer00000000000000000002.regtrans-ms',
 'ntuser.ini',
 'Pictures',
 'PrintHood',
 'Recent',
 'Saved Games',
 'seaborn-data',
 'Searches',
 'SendTo',
 'Templates',
 'Untitled.ipynb',
 'Videos',
 '새파일.txt',
 '새파일1.txt',
 '시작 메뉴']
In [46]:
os.chdir('c:\\users\\user') #현재 작업 디렉토리 바꾸기
In [47]:
os.getcwd() #현재 어디에서 작업하는지 찾기
Out[47]:
'C:\\Users\\user'

모르는 함수는 구글에서 찾아보기

  • io, os, sys
  • math, random, re
  • time, datetime, calendar
  • itertools, functools
  • pickle, json, socket, html, urllib
  • tkinter(GUI)
  • ...

https://docs.python.org/3/library/functions.html

  • timedelta
  • tzinfo
    timezone
  • time
  • date
    datetime
In [53]:
from datetime import datetime
In [54]:
dir(datetime)
Out[54]:
['__add__',
 '__class__',
 '__delattr__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__ne__',
 '__new__',
 '__radd__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__rsub__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__sub__',
 '__subclasshook__',
 'astimezone',
 'combine',
 'ctime',
 'date',
 'day',
 'dst',
 'fold',
 'fromordinal',
 'fromtimestamp',
 'hour',
 'isocalendar',
 'isoformat',
 'isoweekday',
 'max',
 'microsecond',
 'min',
 'minute',
 'month',
 'now',
 'replace',
 'resolution',
 'second',
 'strftime',
 'strptime',
 'time',
 'timestamp',
 'timetuple',
 'timetz',
 'today',
 'toordinal',
 'tzinfo',
 'tzname',
 'utcfromtimestamp',
 'utcnow',
 'utcoffset',
 'utctimetuple',
 'weekday',
 'year']
In [57]:
datetime.now()
Out[57]:
datetime.datetime(2019, 2, 8, 10, 15, 22, 987276)
In [62]:
import random
In [64]:
dir(random)
Out[64]:
['BPF',
 'LOG4',
 'NV_MAGICCONST',
 'RECIP_BPF',
 'Random',
 'SG_MAGICCONST',
 'SystemRandom',
 'TWOPI',
 '_BuiltinMethodType',
 '_MethodType',
 '_Sequence',
 '_Set',
 '__all__',
 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '_acos',
 '_bisect',
 '_ceil',
 '_cos',
 '_e',
 '_exp',
 '_inst',
 '_itertools',
 '_log',
 '_pi',
 '_random',
 '_sha512',
 '_sin',
 '_sqrt',
 '_test',
 '_test_generator',
 '_urandom',
 '_warn',
 'betavariate',
 'choice',
 'choices',
 'expovariate',
 'gammavariate',
 'gauss',
 'getrandbits',
 'getstate',
 'lognormvariate',
 'normalvariate',
 'paretovariate',
 'randint',
 'random',
 'randrange',
 'sample',
 'seed',
 'setstate',
 'shuffle',
 'triangular',
 'uniform',
 'vonmisesvariate',
 'weibullvariate']
In [66]:
help(random.randint)
Help on method randint in module random:

randint(a, b) method of random.Random instance
    Return random integer in range [a, b], including both end points.

In [68]:
random.randint(100,1000)
Out[68]:
284
In [69]:
random.randint(100,1000)
Out[69]:
106
In [70]:
random.randint(100,1000)
Out[70]:
585
In [72]:
import sys
In [73]:
dir(sys)
Out[73]:
['__displayhook__',
 '__doc__',
 '__excepthook__',
 '__interactivehook__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',
 '__stderr__',
 '__stdin__',
 '__stdout__',
 '_clear_type_cache',
 '_current_frames',
 '_debugmallocstats',
 '_enablelegacywindowsfsencoding',
 '_getframe',
 '_git',
 '_home',
 '_xoptions',
 'api_version',
 'argv',
 'base_exec_prefix',
 'base_prefix',
 'builtin_module_names',
 'byteorder',
 'call_tracing',
 'callstats',
 'copyright',
 'displayhook',
 'dllhandle',
 'dont_write_bytecode',
 'exc_info',
 'excepthook',
 'exec_prefix',
 'executable',
 'exit',
 'flags',
 'float_info',
 'float_repr_style',
 'get_asyncgen_hooks',
 'get_coroutine_wrapper',
 'getallocatedblocks',
 'getcheckinterval',
 'getdefaultencoding',
 'getfilesystemencodeerrors',
 'getfilesystemencoding',
 'getprofile',
 'getrecursionlimit',
 'getrefcount',
 'getsizeof',
 'getswitchinterval',
 'gettrace',
 'getwindowsversion',
 'hash_info',
 'hexversion',
 'implementation',
 'int_info',
 'intern',
 'is_finalizing',
 'last_traceback',
 'last_type',
 'last_value',
 'maxsize',
 'maxunicode',
 'meta_path',
 'modules',
 'path',
 'path_hooks',
 'path_importer_cache',
 'platform',
 'prefix',
 'ps1',
 'ps2',
 'ps3',
 'set_asyncgen_hooks',
 'set_coroutine_wrapper',
 'setcheckinterval',
 'setprofile',
 'setrecursionlimit',
 'setswitchinterval',
 'settrace',
 'stderr',
 'stdin',
 'stdout',
 'thread_info',
 'version',
 'version_info',
 'warnoptions',
 'winver']
In [77]:
import urllib
In [78]:
dir(urllib)
Out[78]:
['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 'parse']
In [79]:
urllib.parse('http://google.com')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-79-67b503446eae> in <module>()
----> 1 urllib.parse('http://google.com')

TypeError: 'module' object is not callable
In [84]:
help(urllib.parse)
Help on module urllib.parse in urllib:

NAME
    urllib.parse - Parse (absolute and relative) URLs.

DESCRIPTION
    urlparse module is based upon the following RFC specifications.
    
    RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
    and L.  Masinter, January 2005.
    
    RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
    and L.Masinter, December 1999.
    
    RFC 2396:  "Uniform Resource Identifiers (URI)": Generic Syntax by T.
    Berners-Lee, R. Fielding, and L. Masinter, August 1998.
    
    RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.
    
    RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
    1995.
    
    RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
    McCahill, December 1994
    
    RFC 3986 is considered the current standard and any future changes to
    urlparse module should conform with it.  The urlparse module is
    currently not entirely compliant with this RFC due to defacto
    scenarios for parsing, and for backward compatibility purposes, some
    parsing quirks from older RFCs are retained. The testcases in
    test_urlparse.py provides a good indicator of parsing behavior.

CLASSES
    DefragResult(builtins.tuple)
        DefragResult(DefragResult, _ResultMixinStr)
        DefragResultBytes(DefragResult, _ResultMixinBytes)
    ParseResult(builtins.tuple)
        ParseResult(ParseResult, _NetlocResultMixinStr)
        ParseResultBytes(ParseResult, _NetlocResultMixinBytes)
    SplitResult(builtins.tuple)
        SplitResult(SplitResult, _NetlocResultMixinStr)
        SplitResultBytes(SplitResult, _NetlocResultMixinBytes)
    _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes)
        ParseResultBytes(ParseResult, _NetlocResultMixinBytes)
        SplitResultBytes(SplitResult, _NetlocResultMixinBytes)
    _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr)
        ParseResult(ParseResult, _NetlocResultMixinStr)
        SplitResult(SplitResult, _NetlocResultMixinStr)
    _ResultMixinBytes(builtins.object)
        DefragResultBytes(DefragResult, _ResultMixinBytes)
    _ResultMixinStr(builtins.object)
        DefragResult(DefragResult, _ResultMixinStr)
    
    class DefragResult(DefragResult, _ResultMixinStr)
     |  DefragResult(url, fragment)
     |  
     |  A 2-tuple that contains the url without fragment identifier and the fragment
     |  identifier as a separate argument.
     |  
     |  Method resolution order:
     |      DefragResult
     |      DefragResult
     |      builtins.tuple
     |      _ResultMixinStr
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _encoded_counterpart = <class 'urllib.parse.DefragResultBytes'>
     |      DefragResult(url, fragment)
     |      
     |      A 2-tuple that contains the url without fragment identifier and the fragment
     |      identifier as a separate argument.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from DefragResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new DefragResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from DefragResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new DefragResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from DefragResult:
     |  
     |  __new__(_cls, url, fragment)
     |      Create new instance of DefragResult(url, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from DefragResult:
     |  
     |  url
     |      The URL with no fragment identifier.
     |  
     |  fragment
     |      Fragment identifier separated from URL, that allows indirect identification of a
     |      secondary resource by reference to a primary resource and additional identifying
     |      information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from DefragResult:
     |  
     |  _fields = ('url', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinStr:
     |  
     |  encode(self, encoding='ascii', errors='strict')
    
    class DefragResultBytes(DefragResult, _ResultMixinBytes)
     |  DefragResult(url, fragment)
     |  
     |  A 2-tuple that contains the url without fragment identifier and the fragment
     |  identifier as a separate argument.
     |  
     |  Method resolution order:
     |      DefragResultBytes
     |      DefragResult
     |      builtins.tuple
     |      _ResultMixinBytes
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _decoded_counterpart = <class 'urllib.parse.DefragResult'>
     |      DefragResult(url, fragment)
     |      
     |      A 2-tuple that contains the url without fragment identifier and the fragment
     |      identifier as a separate argument.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from DefragResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new DefragResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from DefragResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new DefragResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from DefragResult:
     |  
     |  __new__(_cls, url, fragment)
     |      Create new instance of DefragResult(url, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from DefragResult:
     |  
     |  url
     |      The URL with no fragment identifier.
     |  
     |  fragment
     |      Fragment identifier separated from URL, that allows indirect identification of a
     |      secondary resource by reference to a primary resource and additional identifying
     |      information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from DefragResult:
     |  
     |  _fields = ('url', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinBytes:
     |  
     |  decode(self, encoding='ascii', errors='strict')
    
    class ParseResult(ParseResult, _NetlocResultMixinStr)
     |  ParseResult(scheme, netloc, path, params,  query, fragment)
     |  
     |  A 6-tuple that contains components of a parsed URL.
     |  
     |  Method resolution order:
     |      ParseResult
     |      ParseResult
     |      builtins.tuple
     |      _NetlocResultMixinStr
     |      _NetlocResultMixinBase
     |      _ResultMixinStr
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _encoded_counterpart = <class 'urllib.parse.ParseResultBytes'>
     |      ParseResult(scheme, netloc, path, params,  query, fragment)
     |      
     |      A 6-tuple that contains components of a parsed URL.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from ParseResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new ParseResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from ParseResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new ParseResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from ParseResult:
     |  
     |  __new__(_cls, scheme, netloc, path, params, query, fragment)
     |      Create new instance of ParseResult(scheme, netloc, path, params, query, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from ParseResult:
     |  
     |  scheme
     |      Specifies URL scheme for the request.
     |  
     |  netloc
     |      Network location where the request is made to.
     |  
     |  path
     |      The hierarchical path, such as the path to a file to download.
     |  
     |  params
     |      Parameters for last path element used to dereference the URI in order to provide
     |      access to perform some operation on the resource.
     |  
     |  query
     |      The query component, that contains non-hierarchical data, that along with data
     |      in path component, identifies a resource in the scope of URI's scheme and
     |      network location.
     |  
     |  fragment
     |      Fragment identifier, that allows indirect identification of a secondary resource
     |      by reference to a primary resource and additional identifying information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from ParseResult:
     |  
     |  _fields = ('scheme', 'netloc', 'path', 'params', 'query', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinStr:
     |  
     |  _hostinfo
     |  
     |  _userinfo
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBase:
     |  
     |  hostname
     |  
     |  password
     |  
     |  port
     |  
     |  username
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinStr:
     |  
     |  encode(self, encoding='ascii', errors='strict')
    
    class ParseResultBytes(ParseResult, _NetlocResultMixinBytes)
     |  ParseResult(scheme, netloc, path, params,  query, fragment)
     |  
     |  A 6-tuple that contains components of a parsed URL.
     |  
     |  Method resolution order:
     |      ParseResultBytes
     |      ParseResult
     |      builtins.tuple
     |      _NetlocResultMixinBytes
     |      _NetlocResultMixinBase
     |      _ResultMixinBytes
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _decoded_counterpart = <class 'urllib.parse.ParseResult'>
     |      ParseResult(scheme, netloc, path, params,  query, fragment)
     |      
     |      A 6-tuple that contains components of a parsed URL.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from ParseResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new ParseResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from ParseResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new ParseResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from ParseResult:
     |  
     |  __new__(_cls, scheme, netloc, path, params, query, fragment)
     |      Create new instance of ParseResult(scheme, netloc, path, params, query, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from ParseResult:
     |  
     |  scheme
     |      Specifies URL scheme for the request.
     |  
     |  netloc
     |      Network location where the request is made to.
     |  
     |  path
     |      The hierarchical path, such as the path to a file to download.
     |  
     |  params
     |      Parameters for last path element used to dereference the URI in order to provide
     |      access to perform some operation on the resource.
     |  
     |  query
     |      The query component, that contains non-hierarchical data, that along with data
     |      in path component, identifies a resource in the scope of URI's scheme and
     |      network location.
     |  
     |  fragment
     |      Fragment identifier, that allows indirect identification of a secondary resource
     |      by reference to a primary resource and additional identifying information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from ParseResult:
     |  
     |  _fields = ('scheme', 'netloc', 'path', 'params', 'query', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBytes:
     |  
     |  _hostinfo
     |  
     |  _userinfo
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBase:
     |  
     |  hostname
     |  
     |  password
     |  
     |  port
     |  
     |  username
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinBytes:
     |  
     |  decode(self, encoding='ascii', errors='strict')
    
    class SplitResult(SplitResult, _NetlocResultMixinStr)
     |  SplitResult(scheme, netloc, path, query, fragment)
     |  
     |  A 5-tuple that contains the different components of a URL. Similar to
     |  ParseResult, but does not split params.
     |  
     |  Method resolution order:
     |      SplitResult
     |      SplitResult
     |      builtins.tuple
     |      _NetlocResultMixinStr
     |      _NetlocResultMixinBase
     |      _ResultMixinStr
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _encoded_counterpart = <class 'urllib.parse.SplitResultBytes'>
     |      SplitResult(scheme, netloc, path, query, fragment)
     |      
     |      A 5-tuple that contains the different components of a URL. Similar to
     |      ParseResult, but does not split params.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from SplitResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new SplitResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from SplitResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new SplitResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from SplitResult:
     |  
     |  __new__(_cls, scheme, netloc, path, query, fragment)
     |      Create new instance of SplitResult(scheme, netloc, path, query, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from SplitResult:
     |  
     |  scheme
     |      Specifies URL scheme for the request.
     |  
     |  netloc
     |      Network location where the request is made to.
     |  
     |  path
     |      The hierarchical path, such as the path to a file to download.
     |  
     |  query
     |      The query component, that contains non-hierarchical data, that along with data
     |      in path component, identifies a resource in the scope of URI's scheme and
     |      network location.
     |  
     |  fragment
     |      Fragment identifier, that allows indirect identification of a secondary resource
     |      by reference to a primary resource and additional identifying information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from SplitResult:
     |  
     |  _fields = ('scheme', 'netloc', 'path', 'query', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinStr:
     |  
     |  _hostinfo
     |  
     |  _userinfo
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBase:
     |  
     |  hostname
     |  
     |  password
     |  
     |  port
     |  
     |  username
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinStr:
     |  
     |  encode(self, encoding='ascii', errors='strict')
    
    class SplitResultBytes(SplitResult, _NetlocResultMixinBytes)
     |  SplitResult(scheme, netloc, path, query, fragment)
     |  
     |  A 5-tuple that contains the different components of a URL. Similar to
     |  ParseResult, but does not split params.
     |  
     |  Method resolution order:
     |      SplitResultBytes
     |      SplitResult
     |      builtins.tuple
     |      _NetlocResultMixinBytes
     |      _NetlocResultMixinBase
     |      _ResultMixinBytes
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  geturl(self)
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  _decoded_counterpart = <class 'urllib.parse.SplitResult'>
     |      SplitResult(scheme, netloc, path, query, fragment)
     |      
     |      A 5-tuple that contains the different components of a URL. Similar to
     |      ParseResult, but does not split params.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from SplitResult:
     |  
     |  __getnewargs__(self)
     |      Return self as a plain tuple.  Used by copy and pickle.
     |  
     |  __repr__(self)
     |      Return a nicely formatted representation string
     |  
     |  _asdict(self)
     |      Return a new OrderedDict which maps field names to their values.
     |  
     |  _replace(_self, **kwds)
     |      Return a new SplitResult object replacing specified fields with new values
     |  
     |  ----------------------------------------------------------------------
     |  Class methods inherited from SplitResult:
     |  
     |  _make(iterable, new=<built-in method __new__ of type object at 0x0000000050B4C0D0>, len=<built-in function len>) from builtins.type
     |      Make a new SplitResult object from a sequence or iterable
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from SplitResult:
     |  
     |  __new__(_cls, scheme, netloc, path, query, fragment)
     |      Create new instance of SplitResult(scheme, netloc, path, query, fragment)
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from SplitResult:
     |  
     |  scheme
     |      Specifies URL scheme for the request.
     |  
     |  netloc
     |      Network location where the request is made to.
     |  
     |  path
     |      The hierarchical path, such as the path to a file to download.
     |  
     |  query
     |      The query component, that contains non-hierarchical data, that along with data
     |      in path component, identifies a resource in the scope of URI's scheme and
     |      network location.
     |  
     |  fragment
     |      Fragment identifier, that allows indirect identification of a secondary resource
     |      by reference to a primary resource and additional identifying information.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from SplitResult:
     |  
     |  _fields = ('scheme', 'netloc', 'path', 'query', 'fragment')
     |  
     |  _source = "from builtins import property as _property, tupl..._itemget...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.tuple:
     |  
     |  __add__(self, value, /)
     |      Return self+value.
     |  
     |  __contains__(self, key, /)
     |      Return key in self.
     |  
     |  __eq__(self, value, /)
     |      Return self==value.
     |  
     |  __ge__(self, value, /)
     |      Return self>=value.
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __getitem__(self, key, /)
     |      Return self[key].
     |  
     |  __gt__(self, value, /)
     |      Return self>value.
     |  
     |  __hash__(self, /)
     |      Return hash(self).
     |  
     |  __iter__(self, /)
     |      Implement iter(self).
     |  
     |  __le__(self, value, /)
     |      Return self<=value.
     |  
     |  __len__(self, /)
     |      Return len(self).
     |  
     |  __lt__(self, value, /)
     |      Return self<value.
     |  
     |  __mul__(self, value, /)
     |      Return self*value.n
     |  
     |  __ne__(self, value, /)
     |      Return self!=value.
     |  
     |  __rmul__(self, value, /)
     |      Return self*value.
     |  
     |  count(...)
     |      T.count(value) -> integer -- return number of occurrences of value
     |  
     |  index(...)
     |      T.index(value, [start, [stop]]) -> integer -- return first index of value.
     |      Raises ValueError if the value is not present.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBytes:
     |  
     |  _hostinfo
     |  
     |  _userinfo
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from _NetlocResultMixinBase:
     |  
     |  hostname
     |  
     |  password
     |  
     |  port
     |  
     |  username
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from _ResultMixinBytes:
     |  
     |  decode(self, encoding='ascii', errors='strict')

FUNCTIONS
    parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace')
        Parse a query given as a string argument.
        
        Arguments:
        
        qs: percent-encoded query string to be parsed
        
        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as
            blank strings.  The default false value indicates that
            blank values are to be ignored and treated as if they were
            not included.
        
        strict_parsing: flag indicating what to do with parsing errors.
            If false (the default), errors are silently ignored.
            If true, errors raise a ValueError exception.
        
        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.
        
        Returns a dictionary.
    
    parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace')
        Parse a query given as a string argument.
        
        Arguments:
        
        qs: percent-encoded query string to be parsed
        
        keep_blank_values: flag indicating whether blank values in
            percent-encoded queries should be treated as blank strings.
            A true value indicates that blanks should be retained as blank
            strings.  The default false value indicates that blank values
            are to be ignored and treated as if they were  not included.
        
        strict_parsing: flag indicating what to do with parsing errors. If
            false (the default), errors are silently ignored. If true,
            errors raise a ValueError exception.
        
        encoding and errors: specify how to decode percent-encoded sequences
            into Unicode characters, as accepted by the bytes.decode() method.
        
        Returns a list, as G-d intended.
    
    quote(string, safe='/', encoding=None, errors=None)
        quote('abc def') -> 'abc%20def'
        
        Each part of a URL, e.g. the path info, the query, etc., has a
        different set of reserved characters that must be quoted.
        
        RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
        the following reserved characters.
        
        reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                      "$" | ","
        
        Each of these characters is reserved in some component of a URL,
        but not necessarily in all of them.
        
        By default, the quote function is intended for quoting the path
        section of a URL.  Thus, it will not encode '/'.  This character
        is reserved, but in typical usage the quote function is being
        called on a path where the existing slash characters are used as
        reserved characters.
        
        string and safe may be either str or bytes objects. encoding and errors
        must not be specified if string is a bytes object.
        
        The optional encoding and errors parameters specify how to deal with
        non-ASCII characters, as accepted by the str.encode method.
        By default, encoding='utf-8' (characters are encoded with UTF-8), and
        errors='strict' (unsupported characters raise a UnicodeEncodeError).
    
    quote_from_bytes(bs, safe='/')
        Like quote(), but accepts a bytes object rather than a str, and does
        not perform string-to-bytes encoding.  It always returns an ASCII string.
        quote_from_bytes(b'abc def?') -> 'abc%20def%3f'
    
    quote_plus(string, safe='', encoding=None, errors=None)
        Like quote(), but also replace ' ' with '+', as required for quoting
        HTML form values. Plus signs in the original string are escaped unless
        they are included in safe. It also does not have safe default to '/'.
    
    unquote(string, encoding='utf-8', errors='replace')
        Replace %xx escapes by their single-character equivalent. The optional
        encoding and errors parameters specify how to decode percent-encoded
        sequences into Unicode characters, as accepted by the bytes.decode()
        method.
        By default, percent-encoded sequences are decoded with UTF-8, and invalid
        sequences are replaced by a placeholder character.
        
        unquote('abc%20def') -> 'abc def'.
    
    unquote_plus(string, encoding='utf-8', errors='replace')
        Like unquote(), but also replace plus signs by spaces, as required for
        unquoting HTML form values.
        
        unquote_plus('%7e/abc+def') -> '~/abc def'
    
    unquote_to_bytes(string)
        unquote_to_bytes('abc%20def') -> b'abc def'.
    
    urldefrag(url)
        Removes any existing fragment from URL.
        
        Returns a tuple of the defragmented URL and the fragment.  If
        the URL contained no fragments, the second element is the
        empty string.
    
    urlencode(query, doseq=False, safe='', encoding=None, errors=None, quote_via=<function quote_plus at 0x000000BB96FD7950>)
        Encode a dict or sequence of two-element tuples into a URL query string.
        
        If any values in the query arg are sequences and doseq is true, each
        sequence element is converted to a separate parameter.
        
        If the query arg is a sequence of two-element tuples, the order of the
        parameters in the output will match the order of parameters in the
        input.
        
        The components of a query arg may each be either a string or a bytes type.
        
        The safe, encoding, and errors parameters are passed down to the function
        specified by quote_via (encoding and errors only if a component is a str).
    
    urljoin(base, url, allow_fragments=True)
        Join a base URL and a possibly relative URL to form an absolute
        interpretation of the latter.
    
    urlparse(url, scheme='', allow_fragments=True)
        Parse a URL into 6 components:
        <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
        Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
        Note that we don't break the components up in smaller bits
        (e.g. netloc is a single string) and we don't expand % escapes.
    
    urlsplit(url, scheme='', allow_fragments=True)
        Parse a URL into 5 components:
        <scheme>://<netloc>/<path>?<query>#<fragment>
        Return a 5-tuple: (scheme, netloc, path, query, fragment).
        Note that we don't break the components up in smaller bits
        (e.g. netloc is a single string) and we don't expand % escapes.
    
    urlunparse(components)
        Put a parsed URL back together again.  This may result in a
        slightly different, but equivalent URL, if the URL that was parsed
        originally had redundant delimiters, e.g. a ? with an empty query
        (the draft states that these are equivalent).
    
    urlunsplit(components)
        Combine the elements of a tuple as returned by urlsplit() into a
        complete URL as a string. The data argument can be any five-item iterable.
        This may result in a slightly different, but equivalent URL, if the URL that
        was parsed originally had unnecessary delimiters (for example, a ? with an
        empty query; the RFC states that these are equivalent).

DATA
    __all__ = ['urlparse', 'urlunparse', 'urljoin', 'urldefrag', 'urlsplit...

FILE
    c:\users\user\anaconda3\lib\urllib\parse.py


윈도우+s : 검색창

anaconda 프롬프트> 마우스 오른쪽 클릭> 속성> 기본위치> 내가 작업하는 디렉토리
아나콘다에서 주피터를 열면 내가 작업하는 디렉토리에서 할 수 있다.
끝나고 ctrl+c를 이용해서 주피터를 열었던 프롬프트에서 빠져나온다.

In [85]:
#제일 마지막 실행 결과만 화면에 출력
1+1
1+2
Out[85]:
3
In [86]:
print(1+1)
1+2
2
Out[86]:
3

esc 상태에서 a를 누르면 위에 b를 누르면 아래에 셀이 추가된다.
dd를 누르면 삭제된다.

In [91]:
f=open('iris.csv')

for line in f:
    print(line)
    
f.close()
SepalLength,SepalWidth,PetalLength,PetalWidth,Name

5.1,3.5,1.4,0.2,Iris-setosa

4.9,3.0,1.4,0.2,Iris-setosa

4.7,3.2,1.3,0.2,Iris-setosa

4.6,3.1,1.5,0.2,Iris-setosa

5.0,3.6,1.4,0.2,Iris-setosa

5.4,3.9,1.7,0.4,Iris-setosa

4.6,3.4,1.4,0.3,Iris-setosa

5.0,3.4,1.5,0.2,Iris-setosa

4.4,2.9,1.4,0.2,Iris-setosa

4.9,3.1,1.5,0.1,Iris-setosa

5.4,3.7,1.5,0.2,Iris-setosa

4.8,3.4,1.6,0.2,Iris-setosa

4.8,3.0,1.4,0.1,Iris-setosa

4.3,3.0,1.1,0.1,Iris-setosa

5.8,4.0,1.2,0.2,Iris-setosa

5.7,4.4,1.5,0.4,Iris-setosa

5.4,3.9,1.3,0.4,Iris-setosa

5.1,3.5,1.4,0.3,Iris-setosa

5.7,3.8,1.7,0.3,Iris-setosa

5.1,3.8,1.5,0.3,Iris-setosa

5.4,3.4,1.7,0.2,Iris-setosa

5.1,3.7,1.5,0.4,Iris-setosa

4.6,3.6,1.0,0.2,Iris-setosa

5.1,3.3,1.7,0.5,Iris-setosa

4.8,3.4,1.9,0.2,Iris-setosa

5.0,3.0,1.6,0.2,Iris-setosa

5.0,3.4,1.6,0.4,Iris-setosa

5.2,3.5,1.5,0.2,Iris-setosa

5.2,3.4,1.4,0.2,Iris-setosa

4.7,3.2,1.6,0.2,Iris-setosa

4.8,3.1,1.6,0.2,Iris-setosa

5.4,3.4,1.5,0.4,Iris-setosa

5.2,4.1,1.5,0.1,Iris-setosa

5.5,4.2,1.4,0.2,Iris-setosa

4.9,3.1,1.5,0.1,Iris-setosa

5.0,3.2,1.2,0.2,Iris-setosa

5.5,3.5,1.3,0.2,Iris-setosa

4.9,3.1,1.5,0.1,Iris-setosa

4.4,3.0,1.3,0.2,Iris-setosa

5.1,3.4,1.5,0.2,Iris-setosa

5.0,3.5,1.3,0.3,Iris-setosa

4.5,2.3,1.3,0.3,Iris-setosa

4.4,3.2,1.3,0.2,Iris-setosa

5.0,3.5,1.6,0.6,Iris-setosa

5.1,3.8,1.9,0.4,Iris-setosa

4.8,3.0,1.4,0.3,Iris-setosa

5.1,3.8,1.6,0.2,Iris-setosa

4.6,3.2,1.4,0.2,Iris-setosa

5.3,3.7,1.5,0.2,Iris-setosa

5.0,3.3,1.4,0.2,Iris-setosa

7.0,3.2,4.7,1.4,Iris-versicolor

6.4,3.2,4.5,1.5,Iris-versicolor

6.9,3.1,4.9,1.5,Iris-versicolor

5.5,2.3,4.0,1.3,Iris-versicolor

6.5,2.8,4.6,1.5,Iris-versicolor

5.7,2.8,4.5,1.3,Iris-versicolor

6.3,3.3,4.7,1.6,Iris-versicolor

4.9,2.4,3.3,1.0,Iris-versicolor

6.6,2.9,4.6,1.3,Iris-versicolor

5.2,2.7,3.9,1.4,Iris-versicolor

5.0,2.0,3.5,1.0,Iris-versicolor

5.9,3.0,4.2,1.5,Iris-versicolor

6.0,2.2,4.0,1.0,Iris-versicolor

6.1,2.9,4.7,1.4,Iris-versicolor

5.6,2.9,3.6,1.3,Iris-versicolor

6.7,3.1,4.4,1.4,Iris-versicolor

5.6,3.0,4.5,1.5,Iris-versicolor

5.8,2.7,4.1,1.0,Iris-versicolor

6.2,2.2,4.5,1.5,Iris-versicolor

5.6,2.5,3.9,1.1,Iris-versicolor

5.9,3.2,4.8,1.8,Iris-versicolor

6.1,2.8,4.0,1.3,Iris-versicolor

6.3,2.5,4.9,1.5,Iris-versicolor

6.1,2.8,4.7,1.2,Iris-versicolor

6.4,2.9,4.3,1.3,Iris-versicolor

6.6,3.0,4.4,1.4,Iris-versicolor

6.8,2.8,4.8,1.4,Iris-versicolor

6.7,3.0,5.0,1.7,Iris-versicolor

6.0,2.9,4.5,1.5,Iris-versicolor

5.7,2.6,3.5,1.0,Iris-versicolor

5.5,2.4,3.8,1.1,Iris-versicolor

5.5,2.4,3.7,1.0,Iris-versicolor

5.8,2.7,3.9,1.2,Iris-versicolor

6.0,2.7,5.1,1.6,Iris-versicolor

5.4,3.0,4.5,1.5,Iris-versicolor

6.0,3.4,4.5,1.6,Iris-versicolor

6.7,3.1,4.7,1.5,Iris-versicolor

6.3,2.3,4.4,1.3,Iris-versicolor

5.6,3.0,4.1,1.3,Iris-versicolor

5.5,2.5,4.0,1.3,Iris-versicolor

5.5,2.6,4.4,1.2,Iris-versicolor

6.1,3.0,4.6,1.4,Iris-versicolor

5.8,2.6,4.0,1.2,Iris-versicolor

5.0,2.3,3.3,1.0,Iris-versicolor

5.6,2.7,4.2,1.3,Iris-versicolor

5.7,3.0,4.2,1.2,Iris-versicolor

5.7,2.9,4.2,1.3,Iris-versicolor

6.2,2.9,4.3,1.3,Iris-versicolor

5.1,2.5,3.0,1.1,Iris-versicolor

5.7,2.8,4.1,1.3,Iris-versicolor

6.3,3.3,6.0,2.5,Iris-virginica

5.8,2.7,5.1,1.9,Iris-virginica

7.1,3.0,5.9,2.1,Iris-virginica

6.3,2.9,5.6,1.8,Iris-virginica

6.5,3.0,5.8,2.2,Iris-virginica

7.6,3.0,6.6,2.1,Iris-virginica

4.9,2.5,4.5,1.7,Iris-virginica

7.3,2.9,6.3,1.8,Iris-virginica

6.7,2.5,5.8,1.8,Iris-virginica

7.2,3.6,6.1,2.5,Iris-virginica

6.5,3.2,5.1,2.0,Iris-virginica

6.4,2.7,5.3,1.9,Iris-virginica

6.8,3.0,5.5,2.1,Iris-virginica

5.7,2.5,5.0,2.0,Iris-virginica

5.8,2.8,5.1,2.4,Iris-virginica

6.4,3.2,5.3,2.3,Iris-virginica

6.5,3.0,5.5,1.8,Iris-virginica

7.7,3.8,6.7,2.2,Iris-virginica

7.7,2.6,6.9,2.3,Iris-virginica

6.0,2.2,5.0,1.5,Iris-virginica

6.9,3.2,5.7,2.3,Iris-virginica

5.6,2.8,4.9,2.0,Iris-virginica

7.7,2.8,6.7,2.0,Iris-virginica

6.3,2.7,4.9,1.8,Iris-virginica

6.7,3.3,5.7,2.1,Iris-virginica

7.2,3.2,6.0,1.8,Iris-virginica

6.2,2.8,4.8,1.8,Iris-virginica

6.1,3.0,4.9,1.8,Iris-virginica

6.4,2.8,5.6,2.1,Iris-virginica

7.2,3.0,5.8,1.6,Iris-virginica

7.4,2.8,6.1,1.9,Iris-virginica

7.9,3.8,6.4,2.0,Iris-virginica

6.4,2.8,5.6,2.2,Iris-virginica

6.3,2.8,5.1,1.5,Iris-virginica

6.1,2.6,5.6,1.4,Iris-virginica

7.7,3.0,6.1,2.3,Iris-virginica

6.3,3.4,5.6,2.4,Iris-virginica

6.4,3.1,5.5,1.8,Iris-virginica

6.0,3.0,4.8,1.8,Iris-virginica

6.9,3.1,5.4,2.1,Iris-virginica

6.7,3.1,5.6,2.4,Iris-virginica

6.9,3.1,5.1,2.3,Iris-virginica

5.8,2.7,5.1,1.9,Iris-virginica

6.8,3.2,5.9,2.3,Iris-virginica

6.7,3.3,5.7,2.5,Iris-virginica

6.7,3.0,5.2,2.3,Iris-virginica

6.3,2.5,5.0,1.9,Iris-virginica

6.5,3.0,5.2,2.0,Iris-virginica

6.2,3.4,5.4,2.3,Iris-virginica

5.9,3.0,5.1,1.8,Iris-virginica
In [92]:
f=open('iris.csv')

for line in f:
    print(line.strip())
    
f.close()
SepalLength,SepalWidth,PetalLength,PetalWidth,Name
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.4,3.2,1.3,0.2,Iris-setosa
5.0,3.5,1.6,0.6,Iris-setosa
5.1,3.8,1.9,0.4,Iris-setosa
4.8,3.0,1.4,0.3,Iris-setosa
5.1,3.8,1.6,0.2,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
4.9,2.4,3.3,1.0,Iris-versicolor
6.6,2.9,4.6,1.3,Iris-versicolor
5.2,2.7,3.9,1.4,Iris-versicolor
5.0,2.0,3.5,1.0,Iris-versicolor
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
5.6,2.9,3.6,1.3,Iris-versicolor
6.7,3.1,4.4,1.4,Iris-versicolor
5.6,3.0,4.5,1.5,Iris-versicolor
5.8,2.7,4.1,1.0,Iris-versicolor
6.2,2.2,4.5,1.5,Iris-versicolor
5.6,2.5,3.9,1.1,Iris-versicolor
5.9,3.2,4.8,1.8,Iris-versicolor
6.1,2.8,4.0,1.3,Iris-versicolor
6.3,2.5,4.9,1.5,Iris-versicolor
6.1,2.8,4.7,1.2,Iris-versicolor
6.4,2.9,4.3,1.3,Iris-versicolor
6.6,3.0,4.4,1.4,Iris-versicolor
6.8,2.8,4.8,1.4,Iris-versicolor
6.7,3.0,5.0,1.7,Iris-versicolor
6.0,2.9,4.5,1.5,Iris-versicolor
5.7,2.6,3.5,1.0,Iris-versicolor
5.5,2.4,3.8,1.1,Iris-versicolor
5.5,2.4,3.7,1.0,Iris-versicolor
5.8,2.7,3.9,1.2,Iris-versicolor
6.0,2.7,5.1,1.6,Iris-versicolor
5.4,3.0,4.5,1.5,Iris-versicolor
6.0,3.4,4.5,1.6,Iris-versicolor
6.7,3.1,4.7,1.5,Iris-versicolor
6.3,2.3,4.4,1.3,Iris-versicolor
5.6,3.0,4.1,1.3,Iris-versicolor
5.5,2.5,4.0,1.3,Iris-versicolor
5.5,2.6,4.4,1.2,Iris-versicolor
6.1,3.0,4.6,1.4,Iris-versicolor
5.8,2.6,4.0,1.2,Iris-versicolor
5.0,2.3,3.3,1.0,Iris-versicolor
5.6,2.7,4.2,1.3,Iris-versicolor
5.7,3.0,4.2,1.2,Iris-versicolor
5.7,2.9,4.2,1.3,Iris-versicolor
6.2,2.9,4.3,1.3,Iris-versicolor
5.1,2.5,3.0,1.1,Iris-versicolor
5.7,2.8,4.1,1.3,Iris-versicolor
6.3,3.3,6.0,2.5,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
7.1,3.0,5.9,2.1,Iris-virginica
6.3,2.9,5.6,1.8,Iris-virginica
6.5,3.0,5.8,2.2,Iris-virginica
7.6,3.0,6.6,2.1,Iris-virginica
4.9,2.5,4.5,1.7,Iris-virginica
7.3,2.9,6.3,1.8,Iris-virginica
6.7,2.5,5.8,1.8,Iris-virginica
7.2,3.6,6.1,2.5,Iris-virginica
6.5,3.2,5.1,2.0,Iris-virginica
6.4,2.7,5.3,1.9,Iris-virginica
6.8,3.0,5.5,2.1,Iris-virginica
5.7,2.5,5.0,2.0,Iris-virginica
5.8,2.8,5.1,2.4,Iris-virginica
6.4,3.2,5.3,2.3,Iris-virginica
6.5,3.0,5.5,1.8,Iris-virginica
7.7,3.8,6.7,2.2,Iris-virginica
7.7,2.6,6.9,2.3,Iris-virginica
6.0,2.2,5.0,1.5,Iris-virginica
6.9,3.2,5.7,2.3,Iris-virginica
5.6,2.8,4.9,2.0,Iris-virginica
7.7,2.8,6.7,2.0,Iris-virginica
6.3,2.7,4.9,1.8,Iris-virginica
6.7,3.3,5.7,2.1,Iris-virginica
7.2,3.2,6.0,1.8,Iris-virginica
6.2,2.8,4.8,1.8,Iris-virginica
6.1,3.0,4.9,1.8,Iris-virginica
6.4,2.8,5.6,2.1,Iris-virginica
7.2,3.0,5.8,1.6,Iris-virginica
7.4,2.8,6.1,1.9,Iris-virginica
7.9,3.8,6.4,2.0,Iris-virginica
6.4,2.8,5.6,2.2,Iris-virginica
6.3,2.8,5.1,1.5,Iris-virginica
6.1,2.6,5.6,1.4,Iris-virginica
7.7,3.0,6.1,2.3,Iris-virginica
6.3,3.4,5.6,2.4,Iris-virginica
6.4,3.1,5.5,1.8,Iris-virginica
6.0,3.0,4.8,1.8,Iris-virginica
6.9,3.1,5.4,2.1,Iris-virginica
6.7,3.1,5.6,2.4,Iris-virginica
6.9,3.1,5.1,2.3,Iris-virginica
5.8,2.7,5.1,1.9,Iris-virginica
6.8,3.2,5.9,2.3,Iris-virginica
6.7,3.3,5.7,2.5,Iris-virginica
6.7,3.0,5.2,2.3,Iris-virginica
6.3,2.5,5.0,1.9,Iris-virginica
6.5,3.0,5.2,2.0,Iris-virginica
6.2,3.4,5.4,2.3,Iris-virginica
5.9,3.0,5.1,1.8,Iris-virginica
In [93]:
f=open('iris.csv')

for line in f:
    print(line.strip().split(','))
    
f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', 'Name']
['5.1', '3.5', '1.4', '0.2', 'Iris-setosa']
['4.9', '3.0', '1.4', '0.2', 'Iris-setosa']
['4.7', '3.2', '1.3', '0.2', 'Iris-setosa']
['4.6', '3.1', '1.5', '0.2', 'Iris-setosa']
['5.0', '3.6', '1.4', '0.2', 'Iris-setosa']
['5.4', '3.9', '1.7', '0.4', 'Iris-setosa']
['4.6', '3.4', '1.4', '0.3', 'Iris-setosa']
['5.0', '3.4', '1.5', '0.2', 'Iris-setosa']
['4.4', '2.9', '1.4', '0.2', 'Iris-setosa']
['4.9', '3.1', '1.5', '0.1', 'Iris-setosa']
['5.4', '3.7', '1.5', '0.2', 'Iris-setosa']
['4.8', '3.4', '1.6', '0.2', 'Iris-setosa']
['4.8', '3.0', '1.4', '0.1', 'Iris-setosa']
['4.3', '3.0', '1.1', '0.1', 'Iris-setosa']
['5.8', '4.0', '1.2', '0.2', 'Iris-setosa']
['5.7', '4.4', '1.5', '0.4', 'Iris-setosa']
['5.4', '3.9', '1.3', '0.4', 'Iris-setosa']
['5.1', '3.5', '1.4', '0.3', 'Iris-setosa']
['5.7', '3.8', '1.7', '0.3', 'Iris-setosa']
['5.1', '3.8', '1.5', '0.3', 'Iris-setosa']
['5.4', '3.4', '1.7', '0.2', 'Iris-setosa']
['5.1', '3.7', '1.5', '0.4', 'Iris-setosa']
['4.6', '3.6', '1.0', '0.2', 'Iris-setosa']
['5.1', '3.3', '1.7', '0.5', 'Iris-setosa']
['4.8', '3.4', '1.9', '0.2', 'Iris-setosa']
['5.0', '3.0', '1.6', '0.2', 'Iris-setosa']
['5.0', '3.4', '1.6', '0.4', 'Iris-setosa']
['5.2', '3.5', '1.5', '0.2', 'Iris-setosa']
['5.2', '3.4', '1.4', '0.2', 'Iris-setosa']
['4.7', '3.2', '1.6', '0.2', 'Iris-setosa']
['4.8', '3.1', '1.6', '0.2', 'Iris-setosa']
['5.4', '3.4', '1.5', '0.4', 'Iris-setosa']
['5.2', '4.1', '1.5', '0.1', 'Iris-setosa']
['5.5', '4.2', '1.4', '0.2', 'Iris-setosa']
['4.9', '3.1', '1.5', '0.1', 'Iris-setosa']
['5.0', '3.2', '1.2', '0.2', 'Iris-setosa']
['5.5', '3.5', '1.3', '0.2', 'Iris-setosa']
['4.9', '3.1', '1.5', '0.1', 'Iris-setosa']
['4.4', '3.0', '1.3', '0.2', 'Iris-setosa']
['5.1', '3.4', '1.5', '0.2', 'Iris-setosa']
['5.0', '3.5', '1.3', '0.3', 'Iris-setosa']
['4.5', '2.3', '1.3', '0.3', 'Iris-setosa']
['4.4', '3.2', '1.3', '0.2', 'Iris-setosa']
['5.0', '3.5', '1.6', '0.6', 'Iris-setosa']
['5.1', '3.8', '1.9', '0.4', 'Iris-setosa']
['4.8', '3.0', '1.4', '0.3', 'Iris-setosa']
['5.1', '3.8', '1.6', '0.2', 'Iris-setosa']
['4.6', '3.2', '1.4', '0.2', 'Iris-setosa']
['5.3', '3.7', '1.5', '0.2', 'Iris-setosa']
['5.0', '3.3', '1.4', '0.2', 'Iris-setosa']
['7.0', '3.2', '4.7', '1.4', 'Iris-versicolor']
['6.4', '3.2', '4.5', '1.5', 'Iris-versicolor']
['6.9', '3.1', '4.9', '1.5', 'Iris-versicolor']
['5.5', '2.3', '4.0', '1.3', 'Iris-versicolor']
['6.5', '2.8', '4.6', '1.5', 'Iris-versicolor']
['5.7', '2.8', '4.5', '1.3', 'Iris-versicolor']
['6.3', '3.3', '4.7', '1.6', 'Iris-versicolor']
['4.9', '2.4', '3.3', '1.0', 'Iris-versicolor']
['6.6', '2.9', '4.6', '1.3', 'Iris-versicolor']
['5.2', '2.7', '3.9', '1.4', 'Iris-versicolor']
['5.0', '2.0', '3.5', '1.0', 'Iris-versicolor']
['5.9', '3.0', '4.2', '1.5', 'Iris-versicolor']
['6.0', '2.2', '4.0', '1.0', 'Iris-versicolor']
['6.1', '2.9', '4.7', '1.4', 'Iris-versicolor']
['5.6', '2.9', '3.6', '1.3', 'Iris-versicolor']
['6.7', '3.1', '4.4', '1.4', 'Iris-versicolor']
['5.6', '3.0', '4.5', '1.5', 'Iris-versicolor']
['5.8', '2.7', '4.1', '1.0', 'Iris-versicolor']
['6.2', '2.2', '4.5', '1.5', 'Iris-versicolor']
['5.6', '2.5', '3.9', '1.1', 'Iris-versicolor']
['5.9', '3.2', '4.8', '1.8', 'Iris-versicolor']
['6.1', '2.8', '4.0', '1.3', 'Iris-versicolor']
['6.3', '2.5', '4.9', '1.5', 'Iris-versicolor']
['6.1', '2.8', '4.7', '1.2', 'Iris-versicolor']
['6.4', '2.9', '4.3', '1.3', 'Iris-versicolor']
['6.6', '3.0', '4.4', '1.4', 'Iris-versicolor']
['6.8', '2.8', '4.8', '1.4', 'Iris-versicolor']
['6.7', '3.0', '5.0', '1.7', 'Iris-versicolor']
['6.0', '2.9', '4.5', '1.5', 'Iris-versicolor']
['5.7', '2.6', '3.5', '1.0', 'Iris-versicolor']
['5.5', '2.4', '3.8', '1.1', 'Iris-versicolor']
['5.5', '2.4', '3.7', '1.0', 'Iris-versicolor']
['5.8', '2.7', '3.9', '1.2', 'Iris-versicolor']
['6.0', '2.7', '5.1', '1.6', 'Iris-versicolor']
['5.4', '3.0', '4.5', '1.5', 'Iris-versicolor']
['6.0', '3.4', '4.5', '1.6', 'Iris-versicolor']
['6.7', '3.1', '4.7', '1.5', 'Iris-versicolor']
['6.3', '2.3', '4.4', '1.3', 'Iris-versicolor']
['5.6', '3.0', '4.1', '1.3', 'Iris-versicolor']
['5.5', '2.5', '4.0', '1.3', 'Iris-versicolor']
['5.5', '2.6', '4.4', '1.2', 'Iris-versicolor']
['6.1', '3.0', '4.6', '1.4', 'Iris-versicolor']
['5.8', '2.6', '4.0', '1.2', 'Iris-versicolor']
['5.0', '2.3', '3.3', '1.0', 'Iris-versicolor']
['5.6', '2.7', '4.2', '1.3', 'Iris-versicolor']
['5.7', '3.0', '4.2', '1.2', 'Iris-versicolor']
['5.7', '2.9', '4.2', '1.3', 'Iris-versicolor']
['6.2', '2.9', '4.3', '1.3', 'Iris-versicolor']
['5.1', '2.5', '3.0', '1.1', 'Iris-versicolor']
['5.7', '2.8', '4.1', '1.3', 'Iris-versicolor']
['6.3', '3.3', '6.0', '2.5', 'Iris-virginica']
['5.8', '2.7', '5.1', '1.9', 'Iris-virginica']
['7.1', '3.0', '5.9', '2.1', 'Iris-virginica']
['6.3', '2.9', '5.6', '1.8', 'Iris-virginica']
['6.5', '3.0', '5.8', '2.2', 'Iris-virginica']
['7.6', '3.0', '6.6', '2.1', 'Iris-virginica']
['4.9', '2.5', '4.5', '1.7', 'Iris-virginica']
['7.3', '2.9', '6.3', '1.8', 'Iris-virginica']
['6.7', '2.5', '5.8', '1.8', 'Iris-virginica']
['7.2', '3.6', '6.1', '2.5', 'Iris-virginica']
['6.5', '3.2', '5.1', '2.0', 'Iris-virginica']
['6.4', '2.7', '5.3', '1.9', 'Iris-virginica']
['6.8', '3.0', '5.5', '2.1', 'Iris-virginica']
['5.7', '2.5', '5.0', '2.0', 'Iris-virginica']
['5.8', '2.8', '5.1', '2.4', 'Iris-virginica']
['6.4', '3.2', '5.3', '2.3', 'Iris-virginica']
['6.5', '3.0', '5.5', '1.8', 'Iris-virginica']
['7.7', '3.8', '6.7', '2.2', 'Iris-virginica']
['7.7', '2.6', '6.9', '2.3', 'Iris-virginica']
['6.0', '2.2', '5.0', '1.5', 'Iris-virginica']
['6.9', '3.2', '5.7', '2.3', 'Iris-virginica']
['5.6', '2.8', '4.9', '2.0', 'Iris-virginica']
['7.7', '2.8', '6.7', '2.0', 'Iris-virginica']
['6.3', '2.7', '4.9', '1.8', 'Iris-virginica']
['6.7', '3.3', '5.7', '2.1', 'Iris-virginica']
['7.2', '3.2', '6.0', '1.8', 'Iris-virginica']
['6.2', '2.8', '4.8', '1.8', 'Iris-virginica']
['6.1', '3.0', '4.9', '1.8', 'Iris-virginica']
['6.4', '2.8', '5.6', '2.1', 'Iris-virginica']
['7.2', '3.0', '5.8', '1.6', 'Iris-virginica']
['7.4', '2.8', '6.1', '1.9', 'Iris-virginica']
['7.9', '3.8', '6.4', '2.0', 'Iris-virginica']
['6.4', '2.8', '5.6', '2.2', 'Iris-virginica']
['6.3', '2.8', '5.1', '1.5', 'Iris-virginica']
['6.1', '2.6', '5.6', '1.4', 'Iris-virginica']
['7.7', '3.0', '6.1', '2.3', 'Iris-virginica']
['6.3', '3.4', '5.6', '2.4', 'Iris-virginica']
['6.4', '3.1', '5.5', '1.8', 'Iris-virginica']
['6.0', '3.0', '4.8', '1.8', 'Iris-virginica']
['6.9', '3.1', '5.4', '2.1', 'Iris-virginica']
['6.7', '3.1', '5.6', '2.4', 'Iris-virginica']
['6.9', '3.1', '5.1', '2.3', 'Iris-virginica']
['5.8', '2.7', '5.1', '1.9', 'Iris-virginica']
['6.8', '3.2', '5.9', '2.3', 'Iris-virginica']
['6.7', '3.3', '5.7', '2.5', 'Iris-virginica']
['6.7', '3.0', '5.2', '2.3', 'Iris-virginica']
['6.3', '2.5', '5.0', '1.9', 'Iris-virginica']
['6.5', '3.0', '5.2', '2.0', 'Iris-virginica']
['6.2', '3.4', '5.4', '2.3', 'Iris-virginica']
['5.9', '3.0', '5.1', '1.8', 'Iris-virginica']
In [97]:
f=open('iris.csv')

data = []

head = f.readline()
head = head
print(head)

f.close()
SepalLength,SepalWidth,PetalLength,PetalWidth,Name

In [98]:
f=open('iris.csv')

data = []

head = f.readline()
head = head.strip()
print(head)

f.close()
SepalLength,SepalWidth,PetalLength,PetalWidth,Name
In [99]:
f=open('iris.csv')

data = []

head = f.readline()
head = head.strip().split(',')
print(head)

f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', 'Name']
In [100]:
f=open('iris.csv')

data = []

head = f.readline()
head = head.strip().split(',')[:4]
print(head)

f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth']

결과창 왼쪽 한번 누르면 짧게, 두번 누르면 사라짐.

In [120]:
f=open('iris.csv')

data = []

head = f.readline()                           # 첫 줄 빠짐
head = head.strip().split(',')[:4]
print(head)

for line in f:
    I = line.strip().split(',')             # 첫 줄 빼고 나머지 150줄을 data 리스트에 집어 넣었다.
    data.append(I)

f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth']
In [103]:
type(data), len(data), data[0]
Out[103]:
(list, 150, ['5.1', '3.5', '1.4', '0.2', 'Iris-setosa'])
In [104]:
data[-1]
Out[104]:
['5.9', '3.0', '5.1', '1.8', 'Iris-virginica']
In [105]:
[i[0] for i in data]

'''
for
'''
Out[105]:
['5.1',
 '4.9',
 '4.7',
 '4.6',
 '5.0',
 '5.4',
 '4.6',
 '5.0',
 '4.4',
 '4.9',
 '5.4',
 '4.8',
 '4.8',
 '4.3',
 '5.8',
 '5.7',
 '5.4',
 '5.1',
 '5.7',
 '5.1',
 '5.4',
 '5.1',
 '4.6',
 '5.1',
 '4.8',
 '5.0',
 '5.0',
 '5.2',
 '5.2',
 '4.7',
 '4.8',
 '5.4',
 '5.2',
 '5.5',
 '4.9',
 '5.0',
 '5.5',
 '4.9',
 '4.4',
 '5.1',
 '5.0',
 '4.5',
 '4.4',
 '5.0',
 '5.1',
 '4.8',
 '5.1',
 '4.6',
 '5.3',
 '5.0',
 '7.0',
 '6.4',
 '6.9',
 '5.5',
 '6.5',
 '5.7',
 '6.3',
 '4.9',
 '6.6',
 '5.2',
 '5.0',
 '5.9',
 '6.0',
 '6.1',
 '5.6',
 '6.7',
 '5.6',
 '5.8',
 '6.2',
 '5.6',
 '5.9',
 '6.1',
 '6.3',
 '6.1',
 '6.4',
 '6.6',
 '6.8',
 '6.7',
 '6.0',
 '5.7',
 '5.5',
 '5.5',
 '5.8',
 '6.0',
 '5.4',
 '6.0',
 '6.7',
 '6.3',
 '5.6',
 '5.5',
 '5.5',
 '6.1',
 '5.8',
 '5.0',
 '5.6',
 '5.7',
 '5.7',
 '6.2',
 '5.1',
 '5.7',
 '6.3',
 '5.8',
 '7.1',
 '6.3',
 '6.5',
 '7.6',
 '4.9',
 '7.3',
 '6.7',
 '7.2',
 '6.5',
 '6.4',
 '6.8',
 '5.7',
 '5.8',
 '6.4',
 '6.5',
 '7.7',
 '7.7',
 '6.0',
 '6.9',
 '5.6',
 '7.7',
 '6.3',
 '6.7',
 '7.2',
 '6.2',
 '6.1',
 '6.4',
 '7.2',
 '7.4',
 '7.9',
 '6.4',
 '6.3',
 '6.1',
 '7.7',
 '6.3',
 '6.4',
 '6.0',
 '6.9',
 '6.7',
 '6.9',
 '5.8',
 '6.8',
 '6.7',
 '6.7',
 '6.3',
 '6.5',
 '6.2',
 '5.9']
In [106]:
data
Out[106]:
[['5.1', '3.5', '1.4', '0.2', 'Iris-setosa'],
 ['4.9', '3.0', '1.4', '0.2', 'Iris-setosa'],
 ['4.7', '3.2', '1.3', '0.2', 'Iris-setosa'],
 ['4.6', '3.1', '1.5', '0.2', 'Iris-setosa'],
 ['5.0', '3.6', '1.4', '0.2', 'Iris-setosa'],
 ['5.4', '3.9', '1.7', '0.4', 'Iris-setosa'],
 ['4.6', '3.4', '1.4', '0.3', 'Iris-setosa'],
 ['5.0', '3.4', '1.5', '0.2', 'Iris-setosa'],
 ['4.4', '2.9', '1.4', '0.2', 'Iris-setosa'],
 ['4.9', '3.1', '1.5', '0.1', 'Iris-setosa'],
 ['5.4', '3.7', '1.5', '0.2', 'Iris-setosa'],
 ['4.8', '3.4', '1.6', '0.2', 'Iris-setosa'],
 ['4.8', '3.0', '1.4', '0.1', 'Iris-setosa'],
 ['4.3', '3.0', '1.1', '0.1', 'Iris-setosa'],
 ['5.8', '4.0', '1.2', '0.2', 'Iris-setosa'],
 ['5.7', '4.4', '1.5', '0.4', 'Iris-setosa'],
 ['5.4', '3.9', '1.3', '0.4', 'Iris-setosa'],
 ['5.1', '3.5', '1.4', '0.3', 'Iris-setosa'],
 ['5.7', '3.8', '1.7', '0.3', 'Iris-setosa'],
 ['5.1', '3.8', '1.5', '0.3', 'Iris-setosa'],
 ['5.4', '3.4', '1.7', '0.2', 'Iris-setosa'],
 ['5.1', '3.7', '1.5', '0.4', 'Iris-setosa'],
 ['4.6', '3.6', '1.0', '0.2', 'Iris-setosa'],
 ['5.1', '3.3', '1.7', '0.5', 'Iris-setosa'],
 ['4.8', '3.4', '1.9', '0.2', 'Iris-setosa'],
 ['5.0', '3.0', '1.6', '0.2', 'Iris-setosa'],
 ['5.0', '3.4', '1.6', '0.4', 'Iris-setosa'],
 ['5.2', '3.5', '1.5', '0.2', 'Iris-setosa'],
 ['5.2', '3.4', '1.4', '0.2', 'Iris-setosa'],
 ['4.7', '3.2', '1.6', '0.2', 'Iris-setosa'],
 ['4.8', '3.1', '1.6', '0.2', 'Iris-setosa'],
 ['5.4', '3.4', '1.5', '0.4', 'Iris-setosa'],
 ['5.2', '4.1', '1.5', '0.1', 'Iris-setosa'],
 ['5.5', '4.2', '1.4', '0.2', 'Iris-setosa'],
 ['4.9', '3.1', '1.5', '0.1', 'Iris-setosa'],
 ['5.0', '3.2', '1.2', '0.2', 'Iris-setosa'],
 ['5.5', '3.5', '1.3', '0.2', 'Iris-setosa'],
 ['4.9', '3.1', '1.5', '0.1', 'Iris-setosa'],
 ['4.4', '3.0', '1.3', '0.2', 'Iris-setosa'],
 ['5.1', '3.4', '1.5', '0.2', 'Iris-setosa'],
 ['5.0', '3.5', '1.3', '0.3', 'Iris-setosa'],
 ['4.5', '2.3', '1.3', '0.3', 'Iris-setosa'],
 ['4.4', '3.2', '1.3', '0.2', 'Iris-setosa'],
 ['5.0', '3.5', '1.6', '0.6', 'Iris-setosa'],
 ['5.1', '3.8', '1.9', '0.4', 'Iris-setosa'],
 ['4.8', '3.0', '1.4', '0.3', 'Iris-setosa'],
 ['5.1', '3.8', '1.6', '0.2', 'Iris-setosa'],
 ['4.6', '3.2', '1.4', '0.2', 'Iris-setosa'],
 ['5.3', '3.7', '1.5', '0.2', 'Iris-setosa'],
 ['5.0', '3.3', '1.4', '0.2', 'Iris-setosa'],
 ['7.0', '3.2', '4.7', '1.4', 'Iris-versicolor'],
 ['6.4', '3.2', '4.5', '1.5', 'Iris-versicolor'],
 ['6.9', '3.1', '4.9', '1.5', 'Iris-versicolor'],
 ['5.5', '2.3', '4.0', '1.3', 'Iris-versicolor'],
 ['6.5', '2.8', '4.6', '1.5', 'Iris-versicolor'],
 ['5.7', '2.8', '4.5', '1.3', 'Iris-versicolor'],
 ['6.3', '3.3', '4.7', '1.6', 'Iris-versicolor'],
 ['4.9', '2.4', '3.3', '1.0', 'Iris-versicolor'],
 ['6.6', '2.9', '4.6', '1.3', 'Iris-versicolor'],
 ['5.2', '2.7', '3.9', '1.4', 'Iris-versicolor'],
 ['5.0', '2.0', '3.5', '1.0', 'Iris-versicolor'],
 ['5.9', '3.0', '4.2', '1.5', 'Iris-versicolor'],
 ['6.0', '2.2', '4.0', '1.0', 'Iris-versicolor'],
 ['6.1', '2.9', '4.7', '1.4', 'Iris-versicolor'],
 ['5.6', '2.9', '3.6', '1.3', 'Iris-versicolor'],
 ['6.7', '3.1', '4.4', '1.4', 'Iris-versicolor'],
 ['5.6', '3.0', '4.5', '1.5', 'Iris-versicolor'],
 ['5.8', '2.7', '4.1', '1.0', 'Iris-versicolor'],
 ['6.2', '2.2', '4.5', '1.5', 'Iris-versicolor'],
 ['5.6', '2.5', '3.9', '1.1', 'Iris-versicolor'],
 ['5.9', '3.2', '4.8', '1.8', 'Iris-versicolor'],
 ['6.1', '2.8', '4.0', '1.3', 'Iris-versicolor'],
 ['6.3', '2.5', '4.9', '1.5', 'Iris-versicolor'],
 ['6.1', '2.8', '4.7', '1.2', 'Iris-versicolor'],
 ['6.4', '2.9', '4.3', '1.3', 'Iris-versicolor'],
 ['6.6', '3.0', '4.4', '1.4', 'Iris-versicolor'],
 ['6.8', '2.8', '4.8', '1.4', 'Iris-versicolor'],
 ['6.7', '3.0', '5.0', '1.7', 'Iris-versicolor'],
 ['6.0', '2.9', '4.5', '1.5', 'Iris-versicolor'],
 ['5.7', '2.6', '3.5', '1.0', 'Iris-versicolor'],
 ['5.5', '2.4', '3.8', '1.1', 'Iris-versicolor'],
 ['5.5', '2.4', '3.7', '1.0', 'Iris-versicolor'],
 ['5.8', '2.7', '3.9', '1.2', 'Iris-versicolor'],
 ['6.0', '2.7', '5.1', '1.6', 'Iris-versicolor'],
 ['5.4', '3.0', '4.5', '1.5', 'Iris-versicolor'],
 ['6.0', '3.4', '4.5', '1.6', 'Iris-versicolor'],
 ['6.7', '3.1', '4.7', '1.5', 'Iris-versicolor'],
 ['6.3', '2.3', '4.4', '1.3', 'Iris-versicolor'],
 ['5.6', '3.0', '4.1', '1.3', 'Iris-versicolor'],
 ['5.5', '2.5', '4.0', '1.3', 'Iris-versicolor'],
 ['5.5', '2.6', '4.4', '1.2', 'Iris-versicolor'],
 ['6.1', '3.0', '4.6', '1.4', 'Iris-versicolor'],
 ['5.8', '2.6', '4.0', '1.2', 'Iris-versicolor'],
 ['5.0', '2.3', '3.3', '1.0', 'Iris-versicolor'],
 ['5.6', '2.7', '4.2', '1.3', 'Iris-versicolor'],
 ['5.7', '3.0', '4.2', '1.2', 'Iris-versicolor'],
 ['5.7', '2.9', '4.2', '1.3', 'Iris-versicolor'],
 ['6.2', '2.9', '4.3', '1.3', 'Iris-versicolor'],
 ['5.1', '2.5', '3.0', '1.1', 'Iris-versicolor'],
 ['5.7', '2.8', '4.1', '1.3', 'Iris-versicolor'],
 ['6.3', '3.3', '6.0', '2.5', 'Iris-virginica'],
 ['5.8', '2.7', '5.1', '1.9', 'Iris-virginica'],
 ['7.1', '3.0', '5.9', '2.1', 'Iris-virginica'],
 ['6.3', '2.9', '5.6', '1.8', 'Iris-virginica'],
 ['6.5', '3.0', '5.8', '2.2', 'Iris-virginica'],
 ['7.6', '3.0', '6.6', '2.1', 'Iris-virginica'],
 ['4.9', '2.5', '4.5', '1.7', 'Iris-virginica'],
 ['7.3', '2.9', '6.3', '1.8', 'Iris-virginica'],
 ['6.7', '2.5', '5.8', '1.8', 'Iris-virginica'],
 ['7.2', '3.6', '6.1', '2.5', 'Iris-virginica'],
 ['6.5', '3.2', '5.1', '2.0', 'Iris-virginica'],
 ['6.4', '2.7', '5.3', '1.9', 'Iris-virginica'],
 ['6.8', '3.0', '5.5', '2.1', 'Iris-virginica'],
 ['5.7', '2.5', '5.0', '2.0', 'Iris-virginica'],
 ['5.8', '2.8', '5.1', '2.4', 'Iris-virginica'],
 ['6.4', '3.2', '5.3', '2.3', 'Iris-virginica'],
 ['6.5', '3.0', '5.5', '1.8', 'Iris-virginica'],
 ['7.7', '3.8', '6.7', '2.2', 'Iris-virginica'],
 ['7.7', '2.6', '6.9', '2.3', 'Iris-virginica'],
 ['6.0', '2.2', '5.0', '1.5', 'Iris-virginica'],
 ['6.9', '3.2', '5.7', '2.3', 'Iris-virginica'],
 ['5.6', '2.8', '4.9', '2.0', 'Iris-virginica'],
 ['7.7', '2.8', '6.7', '2.0', 'Iris-virginica'],
 ['6.3', '2.7', '4.9', '1.8', 'Iris-virginica'],
 ['6.7', '3.3', '5.7', '2.1', 'Iris-virginica'],
 ['7.2', '3.2', '6.0', '1.8', 'Iris-virginica'],
 ['6.2', '2.8', '4.8', '1.8', 'Iris-virginica'],
 ['6.1', '3.0', '4.9', '1.8', 'Iris-virginica'],
 ['6.4', '2.8', '5.6', '2.1', 'Iris-virginica'],
 ['7.2', '3.0', '5.8', '1.6', 'Iris-virginica'],
 ['7.4', '2.8', '6.1', '1.9', 'Iris-virginica'],
 ['7.9', '3.8', '6.4', '2.0', 'Iris-virginica'],
 ['6.4', '2.8', '5.6', '2.2', 'Iris-virginica'],
 ['6.3', '2.8', '5.1', '1.5', 'Iris-virginica'],
 ['6.1', '2.6', '5.6', '1.4', 'Iris-virginica'],
 ['7.7', '3.0', '6.1', '2.3', 'Iris-virginica'],
 ['6.3', '3.4', '5.6', '2.4', 'Iris-virginica'],
 ['6.4', '3.1', '5.5', '1.8', 'Iris-virginica'],
 ['6.0', '3.0', '4.8', '1.8', 'Iris-virginica'],
 ['6.9', '3.1', '5.4', '2.1', 'Iris-virginica'],
 ['6.7', '3.1', '5.6', '2.4', 'Iris-virginica'],
 ['6.9', '3.1', '5.1', '2.3', 'Iris-virginica'],
 ['5.8', '2.7', '5.1', '1.9', 'Iris-virginica'],
 ['6.8', '3.2', '5.9', '2.3', 'Iris-virginica'],
 ['6.7', '3.3', '5.7', '2.5', 'Iris-virginica'],
 ['6.7', '3.0', '5.2', '2.3', 'Iris-virginica'],
 ['6.3', '2.5', '5.0', '1.9', 'Iris-virginica'],
 ['6.5', '3.0', '5.2', '2.0', 'Iris-virginica'],
 ['6.2', '3.4', '5.4', '2.3', 'Iris-virginica'],
 ['5.9', '3.0', '5.1', '1.8', 'Iris-virginica']]
In [113]:
f=open('iris.csv')

data = []

head = f.readline()                           # 첫 줄 빠짐
head = head.strip().split(',')[:4]
print(head)

for line in f:
    I = line.strip().split(',')             # 첫 줄 빼고 나머지 150줄을 data 리스트에 집어 넣었다.
    I[0] = float(I[0])
    I[1] = float(I[1])
    I[2] = float(I[2])
    I[3] = float(I[3])
    data.append(I)

    
    
f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth']
In [114]:
data
Out[114]:
[[5.1, 3.5, 1.4, 0.2, 'Iris-setosa'],
 [4.9, 3.0, 1.4, 0.2, 'Iris-setosa'],
 [4.7, 3.2, 1.3, 0.2, 'Iris-setosa'],
 [4.6, 3.1, 1.5, 0.2, 'Iris-setosa'],
 [5.0, 3.6, 1.4, 0.2, 'Iris-setosa'],
 [5.4, 3.9, 1.7, 0.4, 'Iris-setosa'],
 [4.6, 3.4, 1.4, 0.3, 'Iris-setosa'],
 [5.0, 3.4, 1.5, 0.2, 'Iris-setosa'],
 [4.4, 2.9, 1.4, 0.2, 'Iris-setosa'],
 [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'],
 [5.4, 3.7, 1.5, 0.2, 'Iris-setosa'],
 [4.8, 3.4, 1.6, 0.2, 'Iris-setosa'],
 [4.8, 3.0, 1.4, 0.1, 'Iris-setosa'],
 [4.3, 3.0, 1.1, 0.1, 'Iris-setosa'],
 [5.8, 4.0, 1.2, 0.2, 'Iris-setosa'],
 [5.7, 4.4, 1.5, 0.4, 'Iris-setosa'],
 [5.4, 3.9, 1.3, 0.4, 'Iris-setosa'],
 [5.1, 3.5, 1.4, 0.3, 'Iris-setosa'],
 [5.7, 3.8, 1.7, 0.3, 'Iris-setosa'],
 [5.1, 3.8, 1.5, 0.3, 'Iris-setosa'],
 [5.4, 3.4, 1.7, 0.2, 'Iris-setosa'],
 [5.1, 3.7, 1.5, 0.4, 'Iris-setosa'],
 [4.6, 3.6, 1.0, 0.2, 'Iris-setosa'],
 [5.1, 3.3, 1.7, 0.5, 'Iris-setosa'],
 [4.8, 3.4, 1.9, 0.2, 'Iris-setosa'],
 [5.0, 3.0, 1.6, 0.2, 'Iris-setosa'],
 [5.0, 3.4, 1.6, 0.4, 'Iris-setosa'],
 [5.2, 3.5, 1.5, 0.2, 'Iris-setosa'],
 [5.2, 3.4, 1.4, 0.2, 'Iris-setosa'],
 [4.7, 3.2, 1.6, 0.2, 'Iris-setosa'],
 [4.8, 3.1, 1.6, 0.2, 'Iris-setosa'],
 [5.4, 3.4, 1.5, 0.4, 'Iris-setosa'],
 [5.2, 4.1, 1.5, 0.1, 'Iris-setosa'],
 [5.5, 4.2, 1.4, 0.2, 'Iris-setosa'],
 [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'],
 [5.0, 3.2, 1.2, 0.2, 'Iris-setosa'],
 [5.5, 3.5, 1.3, 0.2, 'Iris-setosa'],
 [4.9, 3.1, 1.5, 0.1, 'Iris-setosa'],
 [4.4, 3.0, 1.3, 0.2, 'Iris-setosa'],
 [5.1, 3.4, 1.5, 0.2, 'Iris-setosa'],
 [5.0, 3.5, 1.3, 0.3, 'Iris-setosa'],
 [4.5, 2.3, 1.3, 0.3, 'Iris-setosa'],
 [4.4, 3.2, 1.3, 0.2, 'Iris-setosa'],
 [5.0, 3.5, 1.6, 0.6, 'Iris-setosa'],
 [5.1, 3.8, 1.9, 0.4, 'Iris-setosa'],
 [4.8, 3.0, 1.4, 0.3, 'Iris-setosa'],
 [5.1, 3.8, 1.6, 0.2, 'Iris-setosa'],
 [4.6, 3.2, 1.4, 0.2, 'Iris-setosa'],
 [5.3, 3.7, 1.5, 0.2, 'Iris-setosa'],
 [5.0, 3.3, 1.4, 0.2, 'Iris-setosa'],
 [7.0, 3.2, 4.7, 1.4, 'Iris-versicolor'],
 [6.4, 3.2, 4.5, 1.5, 'Iris-versicolor'],
 [6.9, 3.1, 4.9, 1.5, 'Iris-versicolor'],
 [5.5, 2.3, 4.0, 1.3, 'Iris-versicolor'],
 [6.5, 2.8, 4.6, 1.5, 'Iris-versicolor'],
 [5.7, 2.8, 4.5, 1.3, 'Iris-versicolor'],
 [6.3, 3.3, 4.7, 1.6, 'Iris-versicolor'],
 [4.9, 2.4, 3.3, 1.0, 'Iris-versicolor'],
 [6.6, 2.9, 4.6, 1.3, 'Iris-versicolor'],
 [5.2, 2.7, 3.9, 1.4, 'Iris-versicolor'],
 [5.0, 2.0, 3.5, 1.0, 'Iris-versicolor'],
 [5.9, 3.0, 4.2, 1.5, 'Iris-versicolor'],
 [6.0, 2.2, 4.0, 1.0, 'Iris-versicolor'],
 [6.1, 2.9, 4.7, 1.4, 'Iris-versicolor'],
 [5.6, 2.9, 3.6, 1.3, 'Iris-versicolor'],
 [6.7, 3.1, 4.4, 1.4, 'Iris-versicolor'],
 [5.6, 3.0, 4.5, 1.5, 'Iris-versicolor'],
 [5.8, 2.7, 4.1, 1.0, 'Iris-versicolor'],
 [6.2, 2.2, 4.5, 1.5, 'Iris-versicolor'],
 [5.6, 2.5, 3.9, 1.1, 'Iris-versicolor'],
 [5.9, 3.2, 4.8, 1.8, 'Iris-versicolor'],
 [6.1, 2.8, 4.0, 1.3, 'Iris-versicolor'],
 [6.3, 2.5, 4.9, 1.5, 'Iris-versicolor'],
 [6.1, 2.8, 4.7, 1.2, 'Iris-versicolor'],
 [6.4, 2.9, 4.3, 1.3, 'Iris-versicolor'],
 [6.6, 3.0, 4.4, 1.4, 'Iris-versicolor'],
 [6.8, 2.8, 4.8, 1.4, 'Iris-versicolor'],
 [6.7, 3.0, 5.0, 1.7, 'Iris-versicolor'],
 [6.0, 2.9, 4.5, 1.5, 'Iris-versicolor'],
 [5.7, 2.6, 3.5, 1.0, 'Iris-versicolor'],
 [5.5, 2.4, 3.8, 1.1, 'Iris-versicolor'],
 [5.5, 2.4, 3.7, 1.0, 'Iris-versicolor'],
 [5.8, 2.7, 3.9, 1.2, 'Iris-versicolor'],
 [6.0, 2.7, 5.1, 1.6, 'Iris-versicolor'],
 [5.4, 3.0, 4.5, 1.5, 'Iris-versicolor'],
 [6.0, 3.4, 4.5, 1.6, 'Iris-versicolor'],
 [6.7, 3.1, 4.7, 1.5, 'Iris-versicolor'],
 [6.3, 2.3, 4.4, 1.3, 'Iris-versicolor'],
 [5.6, 3.0, 4.1, 1.3, 'Iris-versicolor'],
 [5.5, 2.5, 4.0, 1.3, 'Iris-versicolor'],
 [5.5, 2.6, 4.4, 1.2, 'Iris-versicolor'],
 [6.1, 3.0, 4.6, 1.4, 'Iris-versicolor'],
 [5.8, 2.6, 4.0, 1.2, 'Iris-versicolor'],
 [5.0, 2.3, 3.3, 1.0, 'Iris-versicolor'],
 [5.6, 2.7, 4.2, 1.3, 'Iris-versicolor'],
 [5.7, 3.0, 4.2, 1.2, 'Iris-versicolor'],
 [5.7, 2.9, 4.2, 1.3, 'Iris-versicolor'],
 [6.2, 2.9, 4.3, 1.3, 'Iris-versicolor'],
 [5.1, 2.5, 3.0, 1.1, 'Iris-versicolor'],
 [5.7, 2.8, 4.1, 1.3, 'Iris-versicolor'],
 [6.3, 3.3, 6.0, 2.5, 'Iris-virginica'],
 [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'],
 [7.1, 3.0, 5.9, 2.1, 'Iris-virginica'],
 [6.3, 2.9, 5.6, 1.8, 'Iris-virginica'],
 [6.5, 3.0, 5.8, 2.2, 'Iris-virginica'],
 [7.6, 3.0, 6.6, 2.1, 'Iris-virginica'],
 [4.9, 2.5, 4.5, 1.7, 'Iris-virginica'],
 [7.3, 2.9, 6.3, 1.8, 'Iris-virginica'],
 [6.7, 2.5, 5.8, 1.8, 'Iris-virginica'],
 [7.2, 3.6, 6.1, 2.5, 'Iris-virginica'],
 [6.5, 3.2, 5.1, 2.0, 'Iris-virginica'],
 [6.4, 2.7, 5.3, 1.9, 'Iris-virginica'],
 [6.8, 3.0, 5.5, 2.1, 'Iris-virginica'],
 [5.7, 2.5, 5.0, 2.0, 'Iris-virginica'],
 [5.8, 2.8, 5.1, 2.4, 'Iris-virginica'],
 [6.4, 3.2, 5.3, 2.3, 'Iris-virginica'],
 [6.5, 3.0, 5.5, 1.8, 'Iris-virginica'],
 [7.7, 3.8, 6.7, 2.2, 'Iris-virginica'],
 [7.7, 2.6, 6.9, 2.3, 'Iris-virginica'],
 [6.0, 2.2, 5.0, 1.5, 'Iris-virginica'],
 [6.9, 3.2, 5.7, 2.3, 'Iris-virginica'],
 [5.6, 2.8, 4.9, 2.0, 'Iris-virginica'],
 [7.7, 2.8, 6.7, 2.0, 'Iris-virginica'],
 [6.3, 2.7, 4.9, 1.8, 'Iris-virginica'],
 [6.7, 3.3, 5.7, 2.1, 'Iris-virginica'],
 [7.2, 3.2, 6.0, 1.8, 'Iris-virginica'],
 [6.2, 2.8, 4.8, 1.8, 'Iris-virginica'],
 [6.1, 3.0, 4.9, 1.8, 'Iris-virginica'],
 [6.4, 2.8, 5.6, 2.1, 'Iris-virginica'],
 [7.2, 3.0, 5.8, 1.6, 'Iris-virginica'],
 [7.4, 2.8, 6.1, 1.9, 'Iris-virginica'],
 [7.9, 3.8, 6.4, 2.0, 'Iris-virginica'],
 [6.4, 2.8, 5.6, 2.2, 'Iris-virginica'],
 [6.3, 2.8, 5.1, 1.5, 'Iris-virginica'],
 [6.1, 2.6, 5.6, 1.4, 'Iris-virginica'],
 [7.7, 3.0, 6.1, 2.3, 'Iris-virginica'],
 [6.3, 3.4, 5.6, 2.4, 'Iris-virginica'],
 [6.4, 3.1, 5.5, 1.8, 'Iris-virginica'],
 [6.0, 3.0, 4.8, 1.8, 'Iris-virginica'],
 [6.9, 3.1, 5.4, 2.1, 'Iris-virginica'],
 [6.7, 3.1, 5.6, 2.4, 'Iris-virginica'],
 [6.9, 3.1, 5.1, 2.3, 'Iris-virginica'],
 [5.8, 2.7, 5.1, 1.9, 'Iris-virginica'],
 [6.8, 3.2, 5.9, 2.3, 'Iris-virginica'],
 [6.7, 3.3, 5.7, 2.5, 'Iris-virginica'],
 [6.7, 3.0, 5.2, 2.3, 'Iris-virginica'],
 [6.3, 2.5, 5.0, 1.9, 'Iris-virginica'],
 [6.5, 3.0, 5.2, 2.0, 'Iris-virginica'],
 [6.2, 3.4, 5.4, 2.3, 'Iris-virginica'],
 [5.9, 3.0, 5.1, 1.8, 'Iris-virginica']]
In [115]:
f=open('iris.csv')

data = []

head = f.readline()                           # 첫 줄 빠짐
head = head.strip().split(',')[:4]
print(head)

for line in f:
    I = line.strip().split(',')             # 첫 줄 빼고 나머지 150줄을 data 리스트에 집어 넣었다.
    I[0] = float(I[0])         # for문으로 해보기
    I[1] = float(I[1])
    I[2] = float(I[2])
    I[3] = float(I[3])
    data.append(I)

    if I[4] == 'Iris-setosa':       # 딕셔너리를 이용해 해보기
        I[4] = 0
    elif I[4] == 'Iris-versicolor':
        I[4] = 1
    else:
        I[4] = 2
    
f.close()
['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth']
In [116]:
data
Out[116]:
[[5.1, 3.5, 1.4, 0.2, 0],
 [4.9, 3.0, 1.4, 0.2, 0],
 [4.7, 3.2, 1.3, 0.2, 0],
 [4.6, 3.1, 1.5, 0.2, 0],
 [5.0, 3.6, 1.4, 0.2, 0],
 [5.4, 3.9, 1.7, 0.4, 0],
 [4.6, 3.4, 1.4, 0.3, 0],
 [5.0, 3.4, 1.5, 0.2, 0],
 [4.4, 2.9, 1.4, 0.2, 0],
 [4.9, 3.1, 1.5, 0.1, 0],
 [5.4, 3.7, 1.5, 0.2, 0],
 [4.8, 3.4, 1.6, 0.2, 0],
 [4.8, 3.0, 1.4, 0.1, 0],
 [4.3, 3.0, 1.1, 0.1, 0],
 [5.8, 4.0, 1.2, 0.2, 0],
 [5.7, 4.4, 1.5, 0.4, 0],
 [5.4, 3.9, 1.3, 0.4, 0],
 [5.1, 3.5, 1.4, 0.3, 0],
 [5.7, 3.8, 1.7, 0.3, 0],
 [5.1, 3.8, 1.5, 0.3, 0],
 [5.4, 3.4, 1.7, 0.2, 0],
 [5.1, 3.7, 1.5, 0.4, 0],
 [4.6, 3.6, 1.0, 0.2, 0],
 [5.1, 3.3, 1.7, 0.5, 0],
 [4.8, 3.4, 1.9, 0.2, 0],
 [5.0, 3.0, 1.6, 0.2, 0],
 [5.0, 3.4, 1.6, 0.4, 0],
 [5.2, 3.5, 1.5, 0.2, 0],
 [5.2, 3.4, 1.4, 0.2, 0],
 [4.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[6.9, 3.1, 5.4, 2.1],
 [6.7, 3.1, 5.6, 2.4],
 [6.9, 3.1, 5.1, 2.3],
 [5.8, 2.7, 5.1, 1.9],
 [6.8, 3.2, 5.9, 2.3],
 [6.7, 3.3, 5.7, 2.5],
 [6.7, 3.0, 5.2, 2.3],
 [6.3, 2.5, 5.0, 1.9],
 [6.5, 3.0, 5.2, 2.0],
 [6.2, 3.4, 5.4, 2.3],
 [5.9, 3.0, 5.1, 1.8]]
In [119]:
labels = [i[-1] for i in data]
labels
Out[119]:
[0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 0,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 1,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2,
 2]

'beginner > 파이썬 기초' 카테고리의 다른 글

NumPy_랜덤-1  (0) 2019.02.12
NumPy_생성하기  (0) 2019.02.12
NumPy_잘라내기  (0) 2019.02.11
NumPy_기본  (0) 2019.02.08
2019.02.07  (0) 2019.02.07
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
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
글 보관함