⑴ 如何把python安裝的庫刪除

安裝在python上的模塊,可以用pip或者執行setup.py來安裝

如果你是用pip安裝的,可以直接使用pip uninstall 模塊名
如果是用python setup.py install安裝,使用python setup.py uninstall來卸載

或者用最暴力的方法:

python的模塊安裝在python下的LIB目錄下,或Lib\site-packages目錄下,找到模塊直接刪除就可以了

⑵ Python卸載後,隨之的第三方庫會消失嗎

會,庫是關聯的,你卸載了庫會一起被卸載掉

⑶ python中用pip裝了jieba分詞,怎麼刪除重新裝

使用pip安裝可以使用 pip uninstall jieba 卸載
然後使用pip install jieba 重裝

⑷ Python 哪個庫可以刪除Excel表格的某行或某列

openpyxl 2.5以上版本可以刪除Excel表格的某行或某列。

示例代碼

fromopenpyxlimport*。

filename='test.xlsx'。

wb=wb=load_workbook(filename)。

ws=wb.active。

ws.delete_rows(2,2)#刪除回index為2後面的2行。

(4)python刪除庫擴展閱讀:

Python在執行時,首先答會將.py文件中的源代碼編譯成Python的byte code(位元組碼),然後再由Python Virtual Machine(Python虛擬機)來執行這些編譯好的byte code。

這種機制的基本思想跟Java,.NET是一致的。然而,Python Virtual Machine與Java或.NET的Virtual Machine不同的是,Python的Virtual Machine是一種更高級的Virtual Machine。

⑸ python 如何重置釋放導入的庫

reload函數,請點贊

importthis
reload(this)

⑹ 怎麼刪除anaconda里的庫

刪除anaconda里的庫的方法:首先進入anaconda目錄下;然後找到conda-meta文件夾;最後查看此文件夾中是否包含要刪除的包,如果有直接刪除即可。

具體方法:

(推薦教程:Python入門教程)

1、找到anaconda目錄下pkgs文件夾查看是否有要刪除的包,如果有則直接刪除。

2、找到/lib/python3.6/site_packages,查看此文件夾里是否包含要刪除的包,如果有直接刪除。

3、在anaconda目錄下找到conda-meta文件夾,查看此文件夾是否包含要刪除的包的名稱,如果有則直接刪除。

4、執行 conda clean -all命令。

⑺ 後台介面怎麼通過python的requests.delete刪除實例

1、Requests簡介
Requests 是使用 Apache2 Licensed 許可證的 HTTP 庫。用 Python 編寫,真正的為人類著想。
python 標准庫中的 urllib2 模塊提供了你所需要的大多數 HTTP 功能,但是它的 API 太渣了。它是為另一個時代、另一個互聯網所創建的。它需要巨量的工作,甚至包括各種方法覆蓋,來完成最簡單的任務。
總之,大家以後對urllib2庫敬而遠之就行了。來擁抱Requests吧。
Requests的官方文檔:cn.python-requests.org/zh_CN/latest/
通過下面方法安裝requests
[python] view plain
pip install requests
2、Requests如何發送HTTP請求
非常簡單,先導入requests,
[python] view plain
import requests
然後,按照下面的方法發送http的各種請求:
[python] view plain
r = requests.get('githubcom/timeline.json')
r = requests.post("httpbin.org/post")
r = requests.put("httpbin.org/put")
r = requests.delete("httpbin.org/delete")
r = requests.head("httpbin.org/get")
r = requests.options("httpbin.org/get")
3、為URL傳遞參數
如果http請求需要帶URL參數(注意是URL參數不是body參數),那麼需要將參數附帶到payload字典里頭,按照下面的方法發送請求:
[python] view plain
import requests
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get("httpbin.org/get",params=payload)
print r.url
通過print(r.url)能看到URL已被正確編碼:
[python] view plain
httpbin.org/get?key2=value2&key1=value1
注意字典里值為 None 的鍵都不會被添加到 URL 的查詢字元串里。
4、unicode響應內容
[python] view plain
import requests
r = requests.get('githubcom/timeline.json')
r.text
響應結果是:
{"message":"Hello there, wayfaring stranger. If you're reading this then you probably didn't see our blog post a couple of years back announcing that this API would Go away: Git.io/17AROg Fear not, you should be able to get what you need from the shiny new Events API instead.","documentation_url":"developer.githubcom/v3/activity/events/#list-public-events"}
Requests會自動解碼來自伺服器的內容。大多數unicode字元集都能被無縫地解碼。請求發出後,Requests會基於HTTP頭部對響應的編碼作出有根據的推測。當你訪問r.text之時,Requests會使用其推測的文本編碼。你可以找出Requests使用了什麼編碼,並且能夠使用r.encoding 屬性來改變它
>>> r.encoding
'utf-8'
5、二進制響應內容
如果請求返回的是二進制的圖片,你可以使用r.content訪問請求響應體。
[python] view plain
import requests
from PIL import Image
from StringIO import StringIO
r = requests.get('cn.python-requests.org/zh_CN/latest/_static/requests-sidebar.png')
i = Image.open(StringIO(r.content))
i.show()
6、JSON響應內容
Requests中也有一個內置的JSON解碼器,助你處理JSON數據:
[python] view plain
import requests
r = requests.get('githubcom/timeline.json')
print r.json()
r.json將返回的json格式字元串解碼成python字典。r.text返回的utf-8的文本。
7、定製請求頭
如果你想為請求添加HTTP頭部,只要簡單地傳遞一個 dict 給headers 參數就可以了。
[python] view plain
import requests
import json
payload = {'some': 'data'}
headers = {'content-type': 'application/json'}
r = requests.get('githubcom/timeline.json', data=json.mps(payload), headers=headers)
print r.json()
注意,這里的payload是放到body裡面的,所以params參數要使用json數據。
8、POST請求
就像上面『定製請求頭』中的例子,將payload序列化為json格式數據,傳遞給data參數。
9、POST提交文件
先製作一個text文件,名為『report.txt』,內容是『this is a file』。Requests使得上傳多部分編碼文件變得很簡單:
[python] view plain
import requests

url = 'httpbin.org/post'
files = {'file': open('report.txt', 'rb')}
r = requests.post(url, files=files)
print r.text
返回結果是:
[python] view plain
C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/flaskexample/postfile.py
{
"args": {},
"data": "",
"files": {
<strong>"file": "this is a file"</strong>
},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "160",
"Content-Type": "multipart/form-data; boundary=",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.7.0 CPython/2.7.9 Windows/2012Server"
},
"json": null,
"origin": "202.108.92.226",
"url": "httpbin.org/post"
}

Process finished with exit code 0
10、POST提交表單
傳遞一個字典給 data 參數就可以了。數據字典在發出請求時會自動編碼為表單形式:
[python] view plain
>>> payload = {'key1': 'value1', 'key2': 'value2'}
>>> r = requests.post("httpbin.org/post", data=payload)
查看響應內容:
>>> print r.text
{
"args": {},
"data": "",
"files": {},
"form": {
"key1": "value1",
"key2": "value2"
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "23",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.6.0 CPython/2.7.10 Windows/7"
},
"json": null,
"origin": "124.251.251.2",
"url": "httpbin.org/post"
}
11、響應狀態碼
使用r.status_code返回響應的狀態碼。
[python] view plain
import requests

r = requests.get('httpbin.org/get')
print r.status_code
為方便引用,Requests還附帶了一個內置的狀態碼查詢對象:
[python] view plain
print r.status_code == requests.codes.ok
12、失敗請求拋出異常
如果發送了一個失敗請求(非200響應),我們可以通過 Response.raise_for_status()來拋出異常:
[python] view plain
import requests

bad_r = requests.get('httpbin.org/status/404')
print bad_r.status_code
bad_r.raise_for_status()
返回結果是:
[python] view plain
C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/flaskexample/postfile.py
404
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/flaskexample/postfile.py", line 5, in <mole>
bad_r.raise_for_status()
File "C:\Python27\lib\site-packages\requests\models.py", line 851, in raise_for_status
raise HTTPError(http_error_msg, response=self)
<strong>requests.exceptions.HTTPError: 404 Client Error: NOT FOUND</strong>

Process finished with exit code 1
如果返回碼是200,則不會拋出異常,即:
[python] view plain
import requests

bad_r = requests.get('httpbin.org/get')
print bad_r.status_code
bad_r.raise_for_status()
的返回結果是:
[python] view plain
C:\Python27\python.exe C:/Users/Administrator/PycharmProjects/flaskexample/postfile.py
200

Process finished with exit code 0
13、響應頭
我們可以查看以一個Python字典形式展示的伺服器響應頭:
讀取全部頭部:
[python] view plain
r.headers
返回:
{
'content-encoding': 'gzip',
'transfer-encoding': 'chunked',
'connection': 'close',
'server': 'nginx/1.0.4',
'x-runtime': '148ms',
'etag': '""',
'content-type': 'application/json'
}
讀取某一個頭部欄位:
[python] view plain
r.headers['Content-Type']
r.headers.get('content-type')
14、Cookies
得到響應中包含的一些Cookie:
[python] view plain
>>> url = 'examplecom/some/cookie/setting/url'
>>> r = requests.get(url)

>>> r.cookies['example_cookie_name']
'example_cookie_value'
要想發送你的cookies到伺服器,可以使用 cookies 參數:
[python] view plain
>>> url = 'httpbin.org/cookies'
>>> cookies = dict(cookies_are='working')

>>> r = requests.get(url, cookies=cookies)
>>> r.text
返回結果:
u'{\n "cookies": {\n "cookies_are": "working"\n }\n}\n'
15、重定向與請求歷史
默認情況下,除了 HEAD, Requests會自動處理所有重定向。
可以使用響應對象的 history 方法來追蹤重定向。
[python] view plain
>>> r = requests.get('githubcom')
>>> r.url
'githubcom/'
>>> r.status_code
200
>>> r.history
[<Response [301]>]
如果你使用的是GET, OPTIONS, POST, PUT, PATCH 或者 DELETE,,那麼你可以通過 allow_redirects 參數禁用重定向處理:
[python] view plain
>>> r = requests.get('githubcom', allow_redirects=False)
>>> r.status_code
301
>>> r.history
[]
如果你使用的是HEAD,你也可以啟用重定向:
[python] view plain
>>> r = requests.head('githubcom', allow_redirects=True)
>>> r.url
'githubcom/'
>>> r.history
[<Response [301]>]

⑻ python 我怎麼在其他包中對資料庫進行增改刪

execute(self,query,args):執行單條sql語句,接收的參數為sql語句本身和使用的參數列表,返回值為受影響的行數

callproc(self,procname,args):用來執行存儲過程,接收的參數為存儲過程名和參數列表,返回值為受影響的行數

executemany(self,query,args):執行單挑sql語句,但是重復執行參數列表裡的參數,返回值為受影響的行數

⑼ 如何把python安裝的庫刪除

安裝在python上的模來塊,可以用pip或者執行setup.py來安自裝

如果你是用pip安裝的,可以直接使用pip uninstall 模塊名
如果是用python setup.py install安裝,使用python setup.py uninstall來卸載

或者用最暴力的方法:

python的模塊安裝在python下的LIB目錄下,或Lib\site-packages目錄下,找到模塊直接刪除就可以了

⑽ Python 倒入A庫後,如何移除A庫

模塊 import 之後,當然就想卸載或重新載入。不過沒有類似 un-import 這樣的東西。

有 reload() 這個函數,可以回重新載入模塊答的。比如:

import sys
reload(sys)

這樣模塊調試發現問題後,就可以修改並重新載入,重新調試了。

另外需要說明的是,如果有依賴的模塊也修改了,記得先 reload() 依賴的模塊,然後再 reload() 被調試的模塊。