By JULIE PACE and KEN THOMAS, Associated Press

WASHINGTON (AP) — In this heated and deeply divisive campaign year, America's presidential candidates responded Friday with striking reflection and restraint to the week's killings of five police officers and two black men.

Hillary Clinton and Donald Trump quickly scrapped most political events, hours after the officers were killed in Dallas during a protest over the fatal police shootings in Louisiana and Minnesota. Clinton did go forward with a late afternoon appearance at the African Methodist Episcopal Convention in Philadelphia, where she focused on violence from all quarters and declared there is "something wrong with our country."

Addressing the shootings of Alton Sterling in Baton Rouge and Philando Castile in suburban St. Paul, Clinton said that as president she would urge white Americans to gain a better understanding of the anxiety many blacks feel in dealing with law enforcement.

She also spoke sympathetically of the police officers who were killed and their families "who lived every day with the fear that something like this would happen and will always be proud of their service and sacrifice." Her audience applauded when she noted that the police died protecting a march protesting police violence.

However, she also said Americans must "acknowledge that implicit bias still exists across society and even in the best police departments." As president, she said, she plans to commit $1 billion "to find and fund' training programs and research to deal with that.

Trump canceled a speech in Miami on Hispanic issues. He instead posted a Facebook video urging people to "stand in solidarity with law enforcement, which we must remember is the force between civilization and total chaos."

He also called Sterling's and Castile's deaths a reminder of "how much more work we have to do to make every American feel that their safety is protected."

"Now is the time for prayers, love, unity and leadership," Trump said, while vowing to "make America safe again."

Sterling was shot Tuesday after struggling with two white officers who eventually pinned him to the pavement, an altercation that was captured on cellphone video. The following day, Castile was fatally shot in a car by a Minnesota officer, with the aftermath livestreamed on Facebook by his girlfriend.

Hundreds of people gathered in Dallas to protest the killings Thursday night when a gunman opened fire, killing five police officers and injuring seven others. Two civilians were also wounded.

The shootings marked the second time the fledgling general election campaign has been upended by violence. Just one month ago, Clinton and Trump also scrambled their schedules following mass killings at an Orlando gay nightclub.

The political response to that attack was almost instantly contentious, as Republicans and Democrats debated whether the shooting argued for stricter gun laws or tougher anti-terror policies. The gunman had pledged his allegiance to the Islamic State, but law enforcement said there were no indications he had direct ties to extremist groups.

Trump was widely criticized, even by his own party, for taking credit for "being right" on terrorism after the Orlando attacks and for saying he appreciated "the congrats." He was noticeably more measured in his statement Friday but reappeared on Twitter late in the day, taking Clinton to task for her answers to questions in a TV interview about her email practices.

"Isn't it sad that on a day of national tragedy Hillary Clinton is answering softball questions about her email lies on @CNN?" he tweeted.

The response to the shootings from some of Trump's fellow Republicans was also notable. While GOP officials are often seen as siding with the police in recent altercations with black men, some high profile Republicans were pointed Friday in acknowledging racial disparities in policing.

"All of us need to acknowledge that this is about more than just one or two recent incidents," Sen. Marco Rubio of Florida said of this week's shootings. "The fact is that there are communities in America where black families tell us that they are fearful with interacting with local law enforcement. How they feel is a reality that we cannot and should not ignore."

Newt Gingrich, one of the top contenders to be Trump's running mate, said black Americans are "substantially more likely to end up in a situation where the police don't respect you and you could easily get killed."

"I think sometimes for whites it's difficult to appreciate how real that is and how it's an everyday danger," Gingrich said.

President Barack Obama addressed the police shootings from Warsaw, Poland, where he is attending the NATO summit. He said the focus Friday should be on the victims and their families, but added that "when people are armed with powerful weapons, unfortunately, it makes attacks like these more deadly and more tragic."

"In the days ahead, we will have to consider those realities as well," Obama said.

___

Thomas reported from Philadelphia. Associated Press writers Steve Peoples in Washington and Jill Colvin in Miami contributed.

___

What political news is the world searching for on Google and talking about on Twitter? Find out via AP's Election Buzz interactive. http://elections.ap.org/buzz