- 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
- 虚词:副词、介词、连词、助词、拟声词、叹词。
n 名词
nr 人名
#!/usr/bin/python | |
import smtplib | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email.MIMEText import MIMEText | |
from email import Encoders | |
import os | |
gmail_user = "your_email@gmail.com" |
Python Cheatsheet | |
================= | |
################################ Input & Output ############################### | |
name = input('please enter your name: ') | |
print('hello,', name) | |
ageStr = input('please enter your age: ') | |
age = int(ageStr) | |
# List unique values in a DataFrame column | |
pd.unique(df.column_name.ravel()) | |
# Convert Series datatype to numeric, getting rid of any non-numeric values | |
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
# Grab DataFrame rows where column has certain values | |
valuelist = ['value1', 'value2', 'value3'] | |
df = df[df.column.isin(valuelist)] |
import bisect | |
class NFA(object): | |
EPSILON = object() | |
ANY = object() | |
def __init__(self, start_state): | |
self.transitions = {} | |
self.final_states = set() | |
self._start_state = start_state |
#!/usr/bin/env python | |
# coding: utf-8 | |
def dict2dot(foo, bar): | |
for k, v in foo.items(): | |
if not isinstance(v, dict): | |
bar[k] = v | |
continue | |
for kk, vv in v.items(): | |
dict2dot({'{}.{}'.format(k, kk): vv}, bar) |
# pandas输出格式 | |
import pandas as pd | |
pd.set_option('display.height', 1000) | |
pd.set_option('display.max_rows', 500) | |
pd.set_option('display.max_columns', 500) | |
pd.set_option('display.width', 1000) | |
pd.set_option('display.expand_frame_repr', False) | |
# 设置数据格式,避免比较大的数据以科学计数法显示 | |
pd.set_option('display.float_format', lambda x: '%.3f' % x) |
# Working example for my blog post at: | |
# https://danijar.github.io/structuring-your-tensorflow-models | |
import functools | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
def doublewrap(function): | |
""" | |
A decorator decorator, allowing to use the decorator to be used without |