Swiprolog怎样读取文件的内容?
prolog吧
全部回复
仅看楼主
level 9
ichbinlyc
楼主
?- read_string(Stream, L).
读取文件数据流的第一行到变量L。
?- read_string(Stream, 1000,L).
读取文件数据流的头1000个字符到变量L。
当然,之前要先打开文件,获取数据流。
2017年12月08日 02点12分
1
level 9
ichbinlyc
楼主
写入文件
?-write_string().
或者:
?-append()
都可以。
2017年12月08日 08点12分
3
level 9
ichbinlyc
楼主
?- see('test.pl').
打开文件test.pl
也可以用的,二者有一定的区别,
2017年12月10日 05点12分
4
level 9
ichbinlyc
楼主
在上面的基础上读入消息
?- see('t.txt'), read(A),nl,write(A).
A='This is a test.'
2017年12月11日 09点12分
6
1