#17190: 看不懂錯誤的模式--python


abcd9597938 (unknown)

學校 : 不指定學校
編號 : 94775
來源 : [223.136.58.170]
最後登入時間 :
2019-03-26 14:38:08
a009. 解碼器 -- ACM 458 | From: [159.117.69.235] | 發表日期 : 2019-03-24 13:55

import sys
 
for c in sys.stdin:
     s=str(c.strip())
     for single in s:
          mystr=chr(ord(single)-7)
          print(mystr,end="")
 
這段如果打在VScode裡面輸入完亂碼之後按下enter會再度進到sys.stdin,直到按下Cirtl Z,他就會print出解碼並且結束
 
如果打在測試則會發現兩行明碼連在一起
 
 
我嘗試在vscode裡面打成:
 
import sys

for c in sys.stdin:
     s=str(c.strip())
     for single in s:
          mystr=chr(ord(single)-7)
          print(mystr,end="\n")  #因為本來默認就是如此
 
會print出一個字換行一次的明碼
 
--------------------------------------
 
for c in sys.stdin:
     s=str(c.strip())
     for single in s:
          print("here")
          mystr=chr(ord(single)-7)
          print(mystr,end="") 
 
輸入完亂碼結果:
here
*here
Ihere
Bhere
Mhere
here
ihere
...     #又有印了,但是是明碼+"here"+"\n"
 
請教大神為何會如此呢?
 
ZeroJudge Forum