Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

asdfasdf33 seozed

🌴
On vacation
Block or report user

Report or block seozed

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@seozed
seozed / dictwriter_for_csv.py
Created Dec 20, 2018
将字典列表写入到csv文件中
View dictwriter_for_csv.py
import csv
# 字典列表
result_list = []
with open('weibo_data.csv', 'w', newline='', encoding='gbk') as csvfile:
# header field
fieldnames = result_list[0].keys()
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(result_list)
@seozed
seozed / base62.py
Created Jan 11, 2018
62进制转换
View base62.py
ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def base62_encode(num, alphabet=ALPHABET):
"""Encode a number in Base X
`num`: The number to encode
`alphabet`: The alphabet to use for encoding
"""
if (num == 0):
@seozed
seozed / used_concurrent.futures.py
Created Jan 4, 2018
利用concurrent.futures实现多进程示例
View used_concurrent.futures.py
import concurrent.futures
import math
PRIMES = [
112272535095293,
112582705942171,
112272535095293,
115280095190773,
115797848077099,
1099726899285419]
@seozed
seozed / multithreading_demo_1.py
Created Jan 4, 2018
一个高度抽象多线程模块示例
View multithreading_demo_1.py
import concurrent.futures
import urllib.request
URLS = ['http://www.163.com/',
'http://www.qq.com/',
'http://www.baidu.com/',
'http://www.v2ex.com/',
'http://www.360.com']
View example code for pyqt.py
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
# 打开文件对话框,
filename, filetype = QFileDialog.getOpenFileName(None, '选择文件', "", filter="txt (*.txt)")
@seozed
seozed / thread.py
Last active Aug 16, 2018
高度抽象的多线程与多进程库
View thread.py
"""
多进程示例
"""
import time
from multiprocessing import Pool
def run(fn):
time.sleep(1)
print(fn)
@seozed
seozed / diff string.py
Created Nov 8, 2017
比较字符串差异
View diff string.py
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
"""
>>> similar("Apple","Appel")
0.8
>>> similar("Apple","Mango")
0.0
@seozed
seozed / 1.py
Created Nov 7, 2017
v2ex reply code
View 1.py
def foo(**kwargs):
for arg_name in kwargs:
return kwargs[arg_name], arg_name
print(foo(fib=1))
# 输出 (1, 'fib')
@seozed
seozed / get random string.py
Last active Oct 19, 2017
生成随机字符串的方法
View get random string.py
import string
import random
# python 3.6.1以下
text = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(15))
print(text)
# python 3.6.1
text = ''.join(random.choices(string.ascii_letters + string.digits, k=15))
@seozed
seozed / csharp.md
Last active Mar 29, 2017
C# 笔记
View csharp.md
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;

namespace ConsoleApp1
You can’t perform that action at this time.