请用示例代码回答how to send a POST request and handle the response in different programming languages (Python, JavaScript, and Java)，使用markdown表格
user
| 语言       | 示例代码                                                                 |
|------------|------------------------------------------------------------------------|
| Python     | ```python<br>import requests<br><br>url = 'http://example.com/api'<br>data = {'key': 'value'}<br><br>response = requests.post(url, data=data)<br><br>print(response.text)``` |
| JavaScript | ```javascript<br>const url = 'http://example.com/api';<br>const data = {key: 'value'};<br><br>fetch(url, {<br>  method: 'POST',<br>  headers: {'Content-Type': 'application/json'},<br>  body: JSON.stringify(data)<br>})<br>.then(response => response.text())<br>.then(text => console.log(text));``` |
| Java       | ```java<br>import java.net.HttpURLConnection;<br>import java.net.URL;<br>import java.io.OutputStream;<br>import java.io.BufferedReader;<br>import java.io.InputStreamReader;<br><br>public class Main {<br>  public static void main(String[] args) throws Exception {<br>    URL url = new URL("http://example.com/api");<br>    HttpURLConnection conn = (HttpURLConnection) url.openConnection();<br>    conn.setRequestMethod("POST");<br>    conn.setRequestProperty("Content-Type", "application/json;utf-8");<br>    conn.setDoOutput(true);<br><br>    String jsonInputString = "{\"key\": \"value\"}";<br><br>    try(OutputStream os = conn.getOutputStream()) {<br>        byte[] input = jsonInputString.getBytes("utf-8");<br>        os.write(input, 0, input.length);<br>    }<br><br>    try(BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {<br>        StringBuilder response = new StringBuilder();<br>        String responseLine = null;<br>        while ((responseLine = br.readLine()) != null) {<br>            response.append(responseLine.trim());<br>        }<br>        System.out.println(response.toString());<br>    }<br>  }<br>}``` |
assistant