# Day_10
##
+ random ()
+
+ **random()** : 0-1
```
import random
# from random import random
random.random()
# random()
```
+ uniform(a, b) :
+
+ randint(a, b) :
+ randrange(start, stop, [step]) : start, stop (step)
+
+ random.choice(lst) :
```python
# from random import choice
import random
lst = [1,2,3,4,5]
random.choice(lst)
# choice(lst)
```
+
+ random.shuffle() :
+ sys `imort sys`
+ sys.version :
```
>>> sys.version
'3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]'
```
+ sys.path :
```
>>> sys.path
['', 'E:\\PyCharm 2020.2\\python3.7\\python37.zip', 'E:\\PyCharm 2020.2\\python3.7\\DLLs', 'E:\\PyCharm 2020.2\\python3.7\\lib', 'E:\\PyCharm 2020.2\\python3.7', 'E:\\PyCharm 2020.2\\p
ython3.7\\lib\\site-packages', 'E:\\PyCharm 2020.2\\python3.7\\lib\\site-packages\\win32', 'E:\\PyCharm 2020.2\\python3.7\\lib\\site-packages\\win32\\lib', 'E:\\PyCharm 2020.2\\python3
.7\\lib\\site-packages\\Pythonwin']
```
+ sys.argv :
```
import sys
print(sys.argv)
print(ret[0])
print(ret[1])
print(ret[2])
>>>python Day_10.py run start
['Day_10.py', 'run', 'start']
Day_10.py
run
start
```
+ string : `import string`
+ string
```
whitespace = ' \t\n\r\v\f'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = r"""!"#$%&'()*+,-./:;?@[\]^_`{|}~"""
printable = digits + ascii_letters + punctuation + whitespace
```
+ string `dir(str)`
```
>>> dir(string)
['Formatter', 'Template', '_ChainMap', '_TemplateMetaclass', '__all__', '__builtins__',
'__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_re',
'_string', 'ascii_letters', 'ascii_lowercase', 'ascii_uppercase', 'capwords', 'digits', 'hexdigits',
'octdigits', 'printable', 'punctuation', 'whitespace']
```
+ `string.ascii_letters`
```
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
```
+ `string.ascii_uppercase`
```
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
```
+ `string.ascii_lowercase`
```
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
```
+ 0~9 `string.digits`
```
>>> string.digits
'0123456789'
```
+ `string.hexdigits`
(hexdigits = digits + 'abcdef' + 'ABCDEF')
```
>>> string.hexdigits
'0123456789abcdefABCDEF'
```
+ `string.octdigits`
(octdigits = '01234567')
```
>>> string.octdigits
'01234567'
```
+ string.whitespace `string.whitespace`
```
>>> string.whitespace
' \t\n\r\x0b\x0c'
```
+ string.printable ascii_letters `string.printable`
```
>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;?@[\\]^_`{|}~ \t\n\r\x0b\x0c'
```
+ random string
```
>>>''.join(random.sample(string.ascii_letters+string.digits, 6))
'A0yNxY'
```
+ time
+ python
1. ** (timestamp)** [, float]
+ 19701100:00:00
2. ** (struct_time)** []
+ 9 ()
| |
:---: | :---: | :---:
tm_year | | (4 ) 2008
tm_mon | | 1 - 12
tm_mday | | 1 - 31
tm_hour | | 0 - 23
tm_min | | 0 - 59
tm_sec | | 0 - 61 (60 61 )
tm_wday | | 0 - 6 (0 )
tm_yday | | 1 - 366 ()
tm_isdst | | -1, 0, 1 (-1 )
3. **** []
+ : '1999-1-02'
| |
:---: | :---: | :---:
%y | | 00 - 99
%Y | | 000 - 9999
%m | | 01 - 12
%d | | 0 - 31
%H | 24 | 0 - 23
%I | 12 | 01 - 12
%M | | 0 - 59
%S | | 0 - 59
%a |
%A |
%b |
%B |
%c |
%j | | 001 - 366
%p | A.M. P.M.
%U | () | 00 - 53
%w | () | 0 - 6
%W | () | 00 - 53
%x |
%X |
%Z |
%% | %
+ **time.sleep(seconds)** :
+ **time.time()** :
+ : (start, end) end-start
+ **time.localtime(seconds=None**) : ()
```
#
>>> time.localtime()
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=21, tm_hour=10, tm_min=27, tm_sec=27, tm_wday=4, tm_yday=234, tm_isdst=0)
```
+ **time.strftime(format, p_tuple=None)** : ****,
+ format :
+ p_tuple : **** **struct_time** (struct_time time.localtime())
```
>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
'2020-08-21 10:32:50'
>>> time.strftime('%Y-%m-%d %H:%M:%S')
'2020-08-21 10:35:31'
>>> time.strftime('%Y/%m/%d %H:%M:%S')
'2020/08/21 10:36:10'
>>> time.strftime('%x %X')
'08/21/20 10:37:58
```
+
+
+ **time.gmtime(seconds=None)** UTC ( 8 ) time.localtime() ()
```
>>> time.gmtime()
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=21, tm_hour=2, tm_min=48, tm_sec=18, tm_wday=4, tm_yday=234, tm_isdst=0)
>>> time.localtime()
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=21, tm_hour=10, tm_min=48, tm_sec=55, tm_wday=4, tm_yday=234, tm_isdst=0)
```
+
+ **time.mktime()**
```
>>> time.mktime(time.localtime())
1597978194.0
>>> time.mktime(time.gmtime())
1597949433.0
>>> time.time()
1597978205.5068083
```
+
+
+ **time.strftime("", "")**
```
>>> time.strftime('%x %X')
'08/21/20 10:37:58'
```
+
+ **time.strptime("", "")**
```
>>> time.strptime('Fri Aug 21 10:52:32 2020')
time.struct_time(tm_year=2020, tm_mon=8, tm_mday=21, tm_hour=10, tm_min=52, tm_sec=32, tm_wday=4, tm_yday=234, tm_isdst=-1)
>>> time.strptime("2020-2-1", "%Y-%m-%d")
time.struct_time(tm_year=2020, tm_mon=2, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=32, tm_isdst=-1)
```
+ --> %a %b %d %H:%M:%S %Y ( :: )
+ **time.asctime("")**
```
>>> time.asctime()
'Fri Aug 21 10:52:32 2020'
```
+ --> %a %b %d %H:%M:%S %Y ( :: )
+ **time.ctime(""**)
```
>>> time.ctime(time.time())
'Fri Aug 21 10:53:28 2020'
>>> time.ctime(time.mktime(time.localtime()))
'Fri Aug 21 10:54:00 2020'
>>> time.ctime(time.mktime(time.gmtime()))
'Fri Aug 21 02:54:23 2020'
```
+ datetime `import datetime`
+ **datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])**
+
+ tzinfoNonetzinfo
+
```
>>> print(datetime.datetime(2020,3,4,5,5,6))
2020-03-04 05:05:06
```
+ **datetime.date(year, month, day)**
```
>>> print(datetime.date(2020,5,6))
2020-05-06
```
+ **datetime.time(hour, minute, second[, microsecond[, tzinfo]])** 24*60*60
```
>>> print(datetime.time())
00:00:00
>>> print(datetime.time(4,5,6))
04:05:06
```
+ **d = datetime.now()**
```
>>> datetime.datetime.now()
datetime.datetime(2020, 8, 21, 13, 56, 59, 65930)
```
+ d.year
+ d.month
+ d.day
+ d.hour
+ d.minute
+ d.microsecond
+ hashlib () `import hashlib`
+ ['algorithms_available', 'algorithms_guaranteed', 'blake2b', 'blake2s', 'md5', 'new', 'pbkdf2_hmac', 'scrypt', 'sha1', 'sha224', 'sha256', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'shake_128', 'shake_256']
## (Object Oriented Programming OOP)
+
+ :
+ :
+ :
+ :
+ :
+ :
+ (class)
+
```
class :
""""""
def __init__(self, name):
""""""
# :
self.name = name
def study(self):
""""""
```
+
+ (OOA: Object-Oriented Analysis)
+ (OOD: Object-Oriented Design)
+ (OOP: Object-Oriented Programming)
+ (OOT: Object-Oriented Testing)
+ \_\_new\_\_(cls, *args, **kwargs) : () \_\_new\_\_ \_\_init\_\_
+ class(int, str, tuple) metaclass
+ \_\_init\_\_(self) :
+ \_\_str\_\_(self) : \_\_str\_\_
+ \_\_repr\_\_(self) : \_\_repr\_\_,
+ \_\_del\_\_(self) : (),\_\_del\_\_
+ \_\_dict\_\_ :
+ \_\_doc\_\_ :
+ \_\_module\_\_: '\_\_main\_\_.className'mymodclassName.\_\_module\_\_ mymod
+ \_\_bases\_\_ :
+ \_\_cmp\_\_ ( self, x ) : , : cmp(obj, x)