go build -o goencrypt main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"errors" | |
"fmt" | |
_ "github.com/bmizerany/pq" | |
"os" | |
"regexp" | |
"strings" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f, err := os.Open("a.txt") | |
defer f.Close() | |
if nil == err { | |
buff := bufio.NewReader(f) | |
for { | |
line, err := buff.ReadString('\n') | |
if err != nil || io.EOF == err{ | |
break | |
} | |
fmt.Println(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# via: http://www.oschina.net/code/snippet_16840_1568 | |
1.生成随机数 | |
import random #这个是注释,引入模块 | |
rnd = random.randint(1,500)#生成1-500之间的随机数 | |
2.读文件 | |
f = open("c:\\1.txt","r") | |
lines = f.readlines()#读取全部内容 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScript callee 用法示例 | |
function factorial(num) { | |
if (num <= 1) { | |
return 1; | |
} else { | |
return num * arguments.callee(num - 1); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
忽略抛出的异常: | |
常用的写法: | |
try: | |
os.remove('somefile.tmp') | |
except OSError: | |
pass | |
NewerOlder