파이썬은 연습 (97)을 포함한다
제목 : 키보드에서 몇 글자를 입력하면 날짜 번호를 입력 할 때까지 디스크까지 하나씩 넣어.
프로그램 분석 : 없음.
소스 코드 :
#!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': from sys import stdout filename = raw_input('input a file name:\n') fp = open(filename,"w") ch = raw_input('input string:\n') while ch != '#': fp.write(ch) stdout.write(ch) ch = raw_input('') fp.close()
위 예제의 출력은 다음과 같습니다
input a file name: a input string: b b c c#