text = "My phone number is 123-456-7890." pattern = r'\d{3}-\d{3}-\d{4}' match = re.search(pattern, text) if match: print(f"Phone number found: {match.group()}")官方文档: https://docs.python.org/3/howto/regex.html
from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.orm import sessionmaker from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///mydatabase.db') Base = declarative_base()
class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String)
nlp = spacy.load('en_core_web_sm') doc = nlp("This is a sample sentence.") for token in doc: print(token.text, token.pos_)官方文档: https://spacy.io/usage/spacy-101
50、机器学习 - XGBoost
import xgboost as xgb
data = xgb.DMatrix('train.csv') param = {'max_depth': 3, 'eta': 0.1, 'objective': 'reg:squarederror'} model = xgb.train(param, data, 10)官方文档: https://xgboost.readthedocs.io/en/latest/
Last - 云图
今天整理了 50 个常用的Python示例代码。最后,给出咱们开头云图的代码,代码中大家可以自行设置内容和权重。import matplotlib.pyplot as plt from wordcloud import WordCloud