我無法去掉空格和換行符。任何想法可能會出錯?python string strip not striping newline
line_count = 0
word_count = 0
for fline in fh:
line = repr(fline)
line = line.strip()
print line
line_count += 1
word_count += len(line.split())
result['size'] = filesize
result['line'] = line_count
result['words'] = word_count
輸出
'value of $input if it is\n'
' larger than or equal to ygjhg\n'
' that number. Otherwise assigns the value of \n'
' \n'
' '
你爲什麼在這裏使用'repr'? –