[파이썬] 모듈, 파일 사용
파이썬 모듈이란
다른 파일에서 불러와서 쓸수 있는 파일을 모듈이라고함
스탠다드 라이브러리란
사용하고 있는 컴퓨터 언어에 내장되어 있는 라이브러리?
자주쓰는 스탠다드 라이브러리
import random
print(random.randint(1, 20))
print(random.randint(1, 20))
출력
8
3
import random
print(random.uniform(0, 1))
print(random.uniform(0, 1))
출력
0.08811632754196952
0.599056286966887
import datetime
pi_day = datetime.datetime(2020, 3, 14)
print(pi_day)
print(type(pi_day))
출력
2020-03-14 00:00:00
<class 'datetime.datetime'>
today = datetime.datetime.now()
출력
2021-10-15 22:41:24.221660
datetime 포맷 코드
datetime 포맷팅
datetime 포맷 코드
today = datetime.datetime.now()
print(today.strftime("%A, %B %dth %Y"))
출력
Sunday, April 05th 2020input 이란?
input("유저로 부터 값을 입력 받을 수 있는 내장함수")
input("유저로 부터 값을 입력 받을 수 있는 내장함수")❗주의
- 
저장받을 변수를 지정할것 
- 
input에 적은 값이 숫자여도 받은 값의 type은 문자열이라는점 
파일 읽는 법
❗주의
 텍스트 파일에 적혀져있는 각 줄마다 \n 나 \t 가 적혀 있으니 for 루프를 쓸때 기본적으로 whitespace를 제거해주는 함수 strip()을 붙여줄것
strip()
defalut로 문자열에 있는 \t, \n," " 같은 whitespace를 제거하는 함수
파일 쓰는 법
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Author And Source
                            
                            이 문제에 관하여([파이썬] 모듈, 파일 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://velog.io/@dldmsxor1177/파이썬-모듈-파일-사용
                            
                            
                            
                                저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
Author And Source
이 문제에 관하여([파이썬] 모듈, 파일 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@dldmsxor1177/파이썬-모듈-파일-사용저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)