參考網址:https://artem.krylysov.com/blog/2015/09/29/benchmark-python-json-libraries/
安裝:pip install ujson
參考網址:https://artem.krylysov.com/blog/2015/09/29/benchmark-python-json-libraries/
安裝:pip install ujson
伺服端:
MySQL 5.7 Command Line Client輸入指令
mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.6'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>EXIT;
from collections import Counterdata = ['a','2',2,4,5,'2','b',4,7,'a',5,'d','a','z']c = Counter(data)print c.keys()print c.has_key('a')#python3.0移除 改用 if 'a' in c :import pymysql
db = pymysql.connect("localhost","root","password","db_name" )
def openDataBase():
cursor = db.cursor()
cursor.execute("SELECT * FROM tabel_name Join tabel_name2 on tabel_name.id=tabel_name2.id and tabel_name2.category =''category_name")
def writeDB():
cursor = db.cursor()
cursor.execute ("""UPDATE tabel_name
SET 1_rate=%s, 2_rate=%s WHERE id=%s
""", ('1', '1','id'))
db.commit()
常常發現python2方法在python3不一樣,以下只是我遇到的
【SimpleHTTPServer →http.server】
Python 3 the module SimpleHTTPServer has been replaced by http.server, at least in Windows.
原本使用requests但看不見跑到哪,有時候印title當掉appen的東西消失,所以改用chormdiver
from bs4 import BeautifulSoup
import requests
>>>res = requests.get('https://www.kickstarter.com/discover/advanced?term='+parse.quote(title)+'&sort=magic')
>>>soup2 = BeautifulSoup(str(res.text), "lxml")
不知道為什麼中文這麼難找資源OAo
>>>import datetime
>>>import time
>>>endDate='2017/12/6'
>>> time_format=datetime.datetime.strptime(endDate,'%Y/%m/%d').strftime("%B %#d, %Y")
(環境Python3)
打API 有時候遇到字串 有一個 特殊符號 & 他會誤以為是and
所以要把 & 轉 %26
利用 urllib 套件可以完成
>>>from urllib import parse
微軟說 Visual Studio 是世界上最強大的編譯器,python這麼夯,也勢必要提供撰寫環境吧?!
果不出其然是有辦法擴充的!
參考了這個網站 基本上照著安裝就能有不錯的撰寫環境了
https://docs.microsoft.com/zh-tw/visualstudio/python/installing-python-support-in-visual-studio#visual-studio-2015
記得要安裝pthon解譯器,2015前版本都要,目前還只能支援到python3.5
寫python時遇到以下錯誤
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Programs\Python\Python35-32\lib\site-packages\bs4\__init__.py", line 165, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
網路上寫說降版本到3.7.3就可以 但我仍然有這個錯誤 後來我關掉編譯器再打開就沒事了!
不小心就花了2小時一直在糾結....
另一種測試有沒有安裝的方法就是在cmd 輸入 pyhton後 ,再輸入import lxml 沒錯誤就是其實有安裝好