<?php /*比较两个txt文件,格式如下,分别取出a.txt有的b.txt没有的,b.txt有的a.txt没有的及两个都有的 * a.txt: * A * B * C * D * b.txt * A * B * M * N * result: * only_a.txt * C * D * only_b.txt * M * N * public_a_b.txt * A * B */ $curr_file_name = dirname(__FILE__); if (file_exists($cu
package test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import javax.swing.JDialog; public class RuntimeCMD { private static Process p; public static void main(String[] ar
1.文件的读取和显示 方法1: f=open(r'G:\2.txt') print f.read() f.close() 方法2: try: t=open(r'G:\2.txt') print t.read() finally: if t: t.close() 方法3: with open(r'g:\2.txt') as g: for line in g: print line python虽然每次打开文件都要关闭,但是可能会由于异常导致未关闭,因此我们最好是手动关闭,方法二通过异常处理来进行,