Confronting another killing of police officers, President Barack Obama on Sunday urged Americans to tamp down inflammatory words and actions as a violent summer collides with the nation's heated presidential campaign.

Obama said the motive behind Sunday's killing of three officers in Baton Rouge, Louisiana, was still unknown. It was the latest in a string of deadly incidents involving law enforcement, including the police shooting of a black man in Baton Rouge and the killing of five officers in Dallas.

"We as a nation have to be loud and clear that nothing justifies attacks on law enforcement," Obama said in remarks from the White House briefing room.

The president spoke on the eve of the Republican Party's national convention, where Donald Trump will officially accept the GOP nomination. The businessman has cast the recent incidents as a sign that the country needs new leadership, often using heated rhetoric to make his point.

"Every one right now focus on words and actions that can unite this country rather than divide it further," Obama said.

The president spoke earlier Sunday with Louisiana Gov. John Bel Edwards and Baton Rouge Mayor Kip Holden to hear the latest on the investigation into the shootings and pledge federal support.

Obama has spent most of the last week focused on defusing tensions and rebuilding trust between police departments and the communities they serve.

On July 7, an Army veteran opened fire on law enforcement in Dallas, killing five and wounding seven other officers. The shooter, who was black, said he wanted to kill white people, especially white officers. Obama spoke at the memorial service for the officers killed and told Americans not to despair, that the nation is not as divided as it might seem.

The next day, Obama held an extraordinary four-hour meeting at the White House's executive offices with police officers, community activists and elected leaders, emerging from the session saying "we're not even close" to the point where minority communities could feel confident that police departments were serving them with respect and equality or where police departments could feel adequately supported at all levels.

The shooting of the police officers in Dallas and Baton Rouge were preceded by police shootings of two black men, Alton Sterling in Baton Rouge and Philando Castile in suburban St. Paul, Minnesota, which sparked protests around the country. Dallas police were defending protesters in that city when the gunman opened fire on them.