我创建了一个python程序来提供diff文件。想知道将差异的结果发送到.csv的最佳方法是什么
这是我的代码,
import difflib
file1 = "swiss1.csv"
file2 = "swiss2.csv"
diff = difflib.ndiff(open(file1).readlines(),open(file2).readlines())
for line in diff:
if line[0] in ["+", "-"]:
print line
我打算将它打印到CSV文件,而不是打印到终端。思考?
答案 0 :(得分:0)
final ImageButton layerButton = (ImageButton) findViewById(R.id.layers);
final PopupMenu popup = new PopupMenu(MapsActivity.this, layerButton);
popup.getMenuInflater().inflate(R.menu.toolbar_menu, popup.getMenu());
layerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Here
popup.show();
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
handleClicksOnCheckBoxes(item);
return true;
}
});
//And here
popup.show();
}
});