Time of Update: 2018-07-24
Python 2.7 IDE PyCharm 5.0.3 資料分析熱個身啊,反正也看到自然語言處理這塊了。。 講在開頭 此文需要用到的相關知識包括資料清洗,Regex,字典,列表等。不然可能有點費勁。 什麼是N-Gram模型。
Time of Update: 2018-07-24
python發送郵件的介紹比較多,都是需要登入某個郵件服務商,有密碼修改和頻繁發送被限制的問題。這裡介紹一下,調用本機linux自身sendmail服務發送郵件。不需要登入,發送郵件名可以是任意名字,沒有限制。 1. 安裝: #yum install -y sendmail2. 啟動服務: #service sendmail start
Time of Update: 2018-07-24
mac當執行 easy_install PIL 時候報錯 $ easy_install PILSearching for PILReading http://cheeseshop.python.org/pypi/PIL/Reading http://www.pythonware.com/products/pilReading http://effbot.org/downloads/#ImagingReading http://cheeseshop.python.org/pypi/PIL/1.
Time of Update: 2018-07-24
# -*- coding:utf-8 -*-import sysimport osclass test_class(): def hello(self): print(sys._getframe().f_code.co_name)def hello_world(): print('hello_world!') print(sys._getframe().f_code.co_name)if __name__ == '__main__': ttt = test_
Time of Update: 2018-07-24
Mac下安裝python以及jupyter notebook python安裝(anaconda) Mac內建python2版本的python,需要裝的一般都是3版本,anaconda是python的一種版本,anaconda2對應python2版本,anaconda3.6對於python3版本,只需官網下載https://www.continuum.io/downloads/相應版本即可。 下載之後可以預設安裝,直接安裝完成。 安裝完成後,進行如下操作,並啟用。此後用conda
Time of Update: 2018-07-24
上一篇介紹了linspace函數建立等差數列
Time of Update: 2018-07-24
如果是沒有python基礎的同學,建議可以直接下載安裝 anaconda,裡面已經整合了各種資料分析所需模組,這裡不做贅述。 下載地址:https://www.continuum.io/downloads/ 下面來介紹用python安裝以及利用python的pip安裝各個模組方法,pip 是一個安裝和管理 Python 包的工具,pip作為easy_install的替代品。在CPython解譯器,pypy解譯器,可以很好地工作。 1. Python+numpy
Time of Update: 2018-07-24
# coding=utf-8import jsonimport requestsfrom bs4 import BeautifulSoupimport db# 擷取datadef get_data(url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.3
Time of Update: 2018-07-24
有時候,我們在用firepath(不會的請點這裡)查看元素的XPath資訊,發現沒有可以用來定位的id資訊,這個時候我們就需要考慮用其他的可用的來定位元素。本文介紹如何通過元素節點中class name的值來定位頁面元素。還是以百度首頁,搜尋輸入框定位舉例: XPath截圖 相關指令碼代碼如下: # coding=utf-8from selenium import webdriverdriver =
Time of Update: 2018-07-24
前言 插入排序應該是最容易想到的排序演算法,其核心思想是:將待排序的序列看成兩部分,以某一個元素為界,左邊的是排好序的序列,右邊是待排序的序列,每次讀取邊界上的一個元素,然後將它跟排序好的序列中的元素一個一個對比,然後排好序的元素依次挪出個空位,然後將這個元素插入到合適的位置,一直迴圈到序列結束。 插入排序很常見,比如:玩撲克牌時,抓牌的過程就是一個插入排序,每抓到一張牌,就將這張牌插入到手裡排好序的牌中。怎麼個插入法兒呢。比如你手裡的牌是3、6、9,現在你抓到了一張8,你會先跟3比較,
Time of Update: 2018-07-24
稍微總結一下,否則總是忘。 [python] view plaincopyprint? 1. x = 'abc' 2. def fetcher(obj, index): 3. return obj[index] 4.
Time of Update: 2018-07-24
- 首先看一下 df.shift(periods=1, freq=None, axis=0) 的源碼解釋: df.shift?Signature: df.shift(periods=1, freq=None, axis=0)Docstring:Shift index by desired number of periods with an optional time freqParameters----------periods : int Number of periods to
Time of Update: 2018-07-24
語言:Python IDE:Python.IDE 編寫時鐘程式,要求根據時間動態更新 代碼思路 需求:5個Turtle對象, 1個繪製外錶盤+3個類比表上針+1個輸出文字 Step1:建立Turtle對象並初始化 Step2:靜態錶盤繪製 Step3:根據時鐘更新錶針位置與時間資訊 基本庫:Turtle、datetime 程式碼片段 from turtle import *from datetime import *def Skip(step):
Time of Update: 2018-07-24
python內部內建了一個單元測試的模組,pyUnit也就是我們說的:unittest 先介紹下unittest的基本使用方法: 1.import unittest 2.定義一個繼承自unittest.TestCase的測試案例類 3.定義setUp和tearDown,在每個測試案例前後做一些輔助工作。 4.定義測試案例,名字以test開頭。
Time of Update: 2018-07-24
來自於http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python # Import smtplib for the actual sending functionimport smtplib# Import the email modules we'll needfrom email.mime.text import MIMEText# Open a plain text file
Time of Update: 2018-07-24
Python發郵件時報錯 554 錯誤: smtplib.SMTPDataError: (554, b'DT:SPM 163 smtp10,DsCowAA3h9_QbgZXI9_fCQ--.713S2 1460039376,please see http://mail.163.com/help/help_ 解決: 主題不能是test 否則報錯 並且 smtp.sendmail('wangxxxx@126.com', '153xxxx@qq.com',
Time of Update: 2018-07-24
以前的公司上班上網或者收發郵件都得小心翼翼的,怕一不小心被有心人瞧見,又得被說說。為了能發郵件而不被發現,嘿嘿,我就用python寫了個郵件發送程式,用控制台控制,不瞭解的人一定以為哥還在編程工作呢。哈哈。
Time of Update: 2018-07-24
1、安裝相關模組 pip install --upgrade google-cloud 或者 pip install --upgrade google-cloud-translate 2、調用api進行翻譯之前,需要安裝相關認證 官網提供的方法有三種:1、安裝 Google Cloud SDK 下載地址
Time of Update: 2018-07-24
參考連結:How do I send mail from a Python script? 使用linux下的sendmail程式來發送郵件,利用popen函數(python docs關於popen函數)可以直接調用linux系統程式,需要指定程式所在的位置。 #!/usr/bin/python# -*- coding: UTF-8 -*- #Author: Victor LvSENDMAIL = "/usr/sbin/sendmail"
Time of Update: 2018-07-24
下面的例子是QQ郵箱對QQ郵箱的,不知道其他郵箱有什麼不同 (1)首先發送方的smtp服務需要開啟,現在發送的時候需要授權碼 點擊產生授權碼,可能要一些驗證資訊,通過後可以看到授權碼,複製下來 (2)編寫代碼 # -*- coding:utf-8 -*-from email.mime.text import MIMETextfrom email.header import Header# 第一個為常值內容,第二個設定文字格式設定,第三個編碼格式msg =