728x90
# Chapter02-01
# 파이썬 완전 기초
# print 사용법
# 기본 출력
print('Python Start')
print("Python Start")
print()
# separator 옵션
print('p','y','t','h','o','n',sep ='' )
print('p','y','t','h','o','n',sep ='n')
print('p','y','t','h','o','n',sep ='|')
print('p','y','t','h','o','n',sep =' ')
print('0110','7777','1234', sep='-')
print('python','google.com',sep ='@')
print()
# end 옵션
print('Welcome to', end=' ')
print('IT News', end=' ')
print('Web Site', end=' ')
print()
# file 옵션
import sys
print('Learn Python', file = sys.stdout)
print()
# format 사용(d, s, f)
print('%s %s' %('one','two'))
print('{} {}'.format('one','two')) # 비어었을때는 암묵적으로 앞에서 부터 0에서 시작한다고 정해짐
print('{1} {0}'.format('one','two'))
print()
# %s
print('%10s' %('nice'))
print('{:>10}'.format('nice'))
print('%-10s' %('nice'))
print('{:10}'.format('nice'))
print('{:_>10}'.format('nice'))
print('{:$>10}'.format('nice'))
print('{:^10}'.format('nice'))
print('%.5s' % ('nice')) # 절삭하는 기능
print('%.5s' % ('pythonstudy')) # 절삭하는 기능 5자리만 출력
print('{:10.5}'.format('pythonstudy')) # 공간은 10자리르 받아서 5자리만 출력
print()
# %d
print('%d %d' %(1,2))
print('{} {}'.format(1,2))
print('%4d' % (42))
print('{:4d}'.format(42))
print()
# %f
print('%f' %(3.134313232131))
print('%1.8f' %(3.134313232131)) # 1은 정수부 8은 소수부
print('{:f}'.format(3.134313232131))
print('%06.2f' %(3.141592653589793))
print('{:06.2f}'.format(3.141592653589793))
Atom에서 실행시 아래와 같이 출력됨
[Command: python -u C:\python_basic\chapter02_01.py]
Python Start
Python Start
python
pnyntnhnonn
p|y|t|h|o|n
p y t h o n
0110-7777-1234
python@google.com
Welcome to IT News Web Site
Learn Python
one two
one two
two one
nice
nice
nice
nice
______nice
$$$$$$nice
nice
nice
pytho
pytho
1 2
1 2
42
42
3.134313
3.13431323
3.134313
003.14
003.14
[Finished in 0.152s]
728x90
'개발자 모드 > 파이썬(python)' 카테고리의 다른 글
파이썬 변수 선언 완전 기초 (0) | 2021.06.08 |
---|---|
atom python에서 autocomplete-python traceback output 발생 에러 생성시... (0) | 2021.06.05 |
Python Atom에서 실행하는 단축어는 (0) | 2021.06.05 |
python Compiler Atom (0) | 2021.06.05 |
python pyinstaller 설치하기 (0) | 2021.05.27 |