0
我正在從文件p2.txt中讀取一個數字。此文件contrains只有1號是一個整數可以說10使用python從另一個文件中讀取單個數字
test_file = open('p2.txt', 'r')
test_lines = test_file.readlines()
test_file.close()
ferNum= test_lines[0]
print int(ferNum)
不過時,我得到一個錯誤
print int(ferNum)
ValueError: invalid literal for int() with base 10: '1.100000000000000000e+01\n'
我可以看到,它正在考慮它就像一條線。我怎樣才能把這個數字解析成一個變量?有什麼建議麼?至於
你應該包括輸入,否則你會收到狂野的猜測 – JuniorCompressor