python--输入输出

  •   输入sys.stdin 与input 
    • 用input("input promption:")时,实际上是先把提示信息输出,然后捕获输入:
    • 以下两组等价:
    1. hi=input('hello:')
    2. print('hello:',end='')  

hi=sys.stdin.readline()[:-1]   # -1 to discard the '\n' in input stream

  • 输出
  • import sys
  • print('Fatal error:invalid inpurt',file=open("e:\\log.out","w"))  #将错误输出到文件
  • print('Fatal error:invalid inpurt',file=sys.stderr)                     #标准错误输出

  

posted @ 2020-09-07 13:45  lq430430  阅读(135)  评论(0)    收藏  举报