各种语言修复BUG方法

Python

1
2
import webbrowser
webbrowser.open('https://www.baidu.com/')

C++

1
2
3
4
5
6
7
8
#include <stdlib.h>
using namespace std;

int main()
{
system('start https://www.baidu.com/");
return 0;
}

C

1
2
3
4
5
6
7
#include <windows.h>

int main(void)
{
ShellExecute(NULL, 'open', 'https://www.baidu.com/', NULL, NULL, SW_MINIMIZE);
return 0;
}

Java

1
2
java.net.URI uri = new java.net.URI('https://www.baidu.com/');
java.awt.Desktop.getDesktop().browse(uri);

C#

1
System.Diagnostics.Process.Start('https://www.baidu.com/');

PHP

1
2
3
<?php
header('Location: https://www.baidu.com/');
?>

JavaScript

1
window.location.replace('https://www.baidu.com/');

Golang

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import (
'os/exec'
)

func main() {
var url string
var cmd string
var args []string

url = 'https://www.baidu.com/'
switch runtime.GOOS {
case 'windows':
cmd = 'cmd'
args = []string{'/c', 'start'}
case "darwin":
cmd = 'open'
default:
cmd = 'xdg-open'
}
args = append(args, url)
exec.Command(cmd, args...).Start()
}