Thinking/Study

python 출력 테스트

부스 boos 2015. 8. 21. 18:09
728x90

python 함수 테스트


- IP 주소 파싱 테스트

def format_address(address):

    host, port = address.split(':')

    return '%s:%s' % (host or '127.0.0.1', port)


print format_address('1.2.3.4:12345')


- 화면 출력

$ python a.py

1.2.3.4:12345