我写了一个简单的Web服务器来监听端口8080.但我不想使用硬编码的端口号.我想要的是我的服务器监听任何可用的端口.我想知道我的Web服务器正在侦听的端口号.
我的代码如下:
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Run Code Online (Sandbox Code Playgroud) 我试图清理字符串,使其没有任何标点或数字,它必须只有az和AZ.例如,给定String是:
"coMPuter scien_tist-s are,,, the rock__stars of tomorrow_ <cool> ????"
Run Code Online (Sandbox Code Playgroud)
所需的输出是:
['computer', 'scientists', 'are', 'the', 'rockstars', 'of', 'tomorrow']
Run Code Online (Sandbox Code Playgroud)
我的解决方案是
re.findall(r"([A-Za-z]+)" ,string)
Run Code Online (Sandbox Code Playgroud)
我的输出是
['coMPuter', 'scien', 'tist', 's', 'are', 'the', 'rock', 'stars', 'of', 'tomorrow', 'cool']
Run Code Online (Sandbox Code Playgroud)