//replace the line breaks "\n" with System line separator...
//replace "yourTextAreaVariabe" with your own...
yourTextAreaVariable.getText().replaceAll("\n", System.getProperty("line.separator"));
即使生成了正确的文件名且文件存在
,我的文件也无法打开答案 0 :(得分:1)
就个人而言,我会将最后一行替换为:
with open(configuration_file+'.txt','r') as f:
line=f.readline()
print(line)
...
这样你就不必关闭文件了。
我还会在开放之前添加一张支票:
import os, sys
if not os.path.isfile(configuration_file+'.txt'):
print('error: file not found')
sys.exit(-1)