![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
酸柠檬水
这个作者很懒,什么都没留下…
展开
-
Python 中的 if __name__ == '__main__' 该如何理解
1. 如果模块是被导入,__name__的值为模块名字2. 如果模块是被直接执行,__name__的值为’__main__’理解:_name_是系统内置变量代表文件模块名 ,当.py文件以模块的形式导入清晰地反映一个模块在包中的层次,通过print(_name_) 可以输入对应的包名(可以看出包结构) 当.py文件被直接运行时则其没有包结构,其__name__值为__main_...转载 2019-04-12 11:09:10 · 106 阅读 · 0 评论 -
pdfminer PDF转word txt
from pdfminer.pdfparser import PDFParser, PDFDocumentfrom pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreterfrom pdfminer.layout import LAParamsfrom pdfminer.converter import PDFPage...原创 2019-05-21 18:18:06 · 1210 阅读 · 0 评论 -
Python 中的几种矩阵乘法 np.dot, np.multiply, *
矩阵中np.dot 一维对应相乘=》数值(相当于向量点乘)二位点乘=》对应矩阵(内部相当于向量点乘)np.multiply(), 或 * 元素对应相乘,要求shape相同import numpy as npa = np.array([1,2,3,4])b = np.array([1,2,3,4])np.dot(a,b) =&...原创 2019-06-05 11:57:41 · 362 阅读 · 0 评论 -
numpy 广播
以两个矩阵 谁的行大 沿谁行扩 谁的列大 沿谁列扩 (暂时遇到是这样 如有不对感谢指正)除行列不缺失 且 都不等:a = np.array([[1.0, 2.0, 3.0], [1.0, 2.0, 3.0], [1.0, 2.0, 3.0]] ...原创 2019-06-05 18:37:03 · 885 阅读 · 0 评论 -
python 避错
=》生成数组最好(n,1) or (1,n) 广播机制弊端 不知道什么时候就出错了=》不知道形状多用reshape=》assert() 写程序时候,与其让它运行时崩溃,不如在它出现错误条件时就崩溃(返回错误)。断言assert 就显得非常有用。assert的语法格式: assert expression它的等价语句为:if not ...原创 2019-06-05 18:55:04 · 97 阅读 · 0 评论 -
python 里 np.array 的shape ( ,)与( ,1)的区别
https://blog.csdn.net/weixin_39449570/article/details/78645618>>> import numpy as np>>> x = np.array([1, 2])>>> y = np.array([[1],[2]])>>> z = np.array([[1,2]...原创 2019-06-05 21:14:35 · 750 阅读 · 0 评论 -
Numpy中shape(宽,高,层) dot点乘 outer外积
dot outer ==》https://blog.csdn.net/hqh131360239/article/details/79064592三维shape(宽,高,层)np.dot()执行矩阵 - 矩阵或矩阵 - 向量乘法。这与np.multiply()和*运算符(相当于Matlab / Octave中的。*)不同,后者执行逐元素乘法。1、dot...原创 2019-06-05 21:55:43 · 915 阅读 · 0 评论 -
python 列表 为什么
def ina(): a=[] print('ok') a.append(2)a=[1]ina()print(a)def ina(): print('ok') a.append(2)a=[1]ina()print(a)class Ina: def __init__(self): ...原创 2019-06-07 12:02:55 · 113 阅读 · 0 评论 -
python 抓取json 天气信息
#! python3# quickWeather.py - Prints the current weather for a location from the command line.import json, requests, sys# Compute location from command line arguments.location = 'San Francisco...原创 2019-04-11 16:18:59 · 228 阅读 · 0 评论 -
selenium学习
selenium中文文档=》https://python-selenium-zh.readthedocs.io/zh_CN/latest/Python3+selenium3+Firefox 无界面模式 设置浏览器headless模式运行+下载文件=》https://www.jianshu.com/p/ab09441cbc07Firefox Chrome下载文件:https://www.c...原创 2019-05-21 12:21:56 · 165 阅读 · 0 评论 -
Python多线程可重入
# encoding: UTF-8import threadingimport timeclass MyThread(threading.Thread): def do1(self): global resA, resB if mutexA.acquire():msg = self.name+' got resA' prin...转载 2019-05-09 08:58:44 · 227 阅读 · 0 评论 -
漫画自动获取并下载
单线程下载:#! python3# downloadXkcd.py - Downloads every single XKCD comic.import requests, os, bs4url = 'http://xkcd.com' # starting urlos.makedirs('xkcd', exist_ok=True) # store comics in ./xkc...原创 2019-04-12 16:20:49 · 583 阅读 · 0 评论 -
IMAP
import imapclient,pprintimapObj=imapclient.IMAPClient('imap.163.com',ssl=True)imapObj.login('***@163.com','***715')pprint.pprint(imapObj.list_folders())imapObj.select_folder('INBOX',readonly=True...原创 2019-04-13 16:15:39 · 424 阅读 · 0 评论 -
向会员发送会费提醒电子邮件
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.image import MIMEImage from email.header import Header import op...原创 2019-04-13 19:51:18 · 365 阅读 · 0 评论 -
股票趋势预测
#!/usr/bin/python# -*- coding: utf-8 -*-# forecast.pyfrom __future__ import print_functionimport datetimeimport numpy as npimport pandas as pdimport sklearnfrom pandas_datareader import D...转载 2019-04-16 20:00:14 · 1048 阅读 · 0 评论 -
Python免费发短信
from twilio.rest import Clientaccount_sid = "AC29f5dbfe0cbf84efdbed96832b7a5bc4" #初始界面显示的账号idauth_token = "8f******" #初始界面现实的token,用于验证账号client = Client(account_sid,auth_token) #生成一个客户端对象pr...原创 2019-04-13 23:07:59 · 854 阅读 · 0 评论 -
安卓打电话
from time import sleepimport osnumbers = [10086,1008611,10010,12580]for number in numbers: #拨打电话 call = os.popen('adb shell am start -a android.intent.action.CALL -d tel:{}'.format(number)...翻译 2019-04-14 11:26:40 · 205 阅读 · 0 评论 -
股票预测
#!/usr/bin/python# -*- coding: utf-8 -*-# forecast.pyfrom __future__ import print_functionimport datetimeimport numpy as npimport pandas as pdimport sklearnfrom pandas_datareader impor...转载 2019-04-17 11:26:24 · 286 阅读 · 0 评论 -
python 多线程编程
import threadingimport timeclass MyThread(threading.Thread): def run(self): global num time.sleep(2) num = num+1 print('neiron') msg = self.name+' set nu...转载 2019-05-08 17:12:53 · 114 阅读 · 0 评论 -
Python 控制台输入
单行#sys.stdin.readline() numList= list(map(int,sys.stdin.readline().strip().split()))print(numList)12 23 34[12, 23, 34]strList=sys.stdin.readline().strip().split()print(strList)23 df fg 45...原创 2019-08-24 12:05:25 · 2588 阅读 · 0 评论