Time of Update: 2016-12-17
標籤:學習記錄今日學習記錄模組:import os#匯入os模組import sys#匯入sys模組os.system("df -h")#執行df -h命令cmd_res = os.popen("df -h").read()#將命令的返回結果賦值給cmd_res,如果不加入.read()會顯示命令的返回加過在記憶體的位置print(sys.path)#顯示系統變數路徑,一般個人模組位於site-packages下,系統模組位於
Time of Update: 2016-12-17
標籤:python營運 掃描連接埠 介紹python-nmap是基於系統nmap命令的一個連接埠掃描工具,使用簡單方便。最近為了加強伺服器安全性和監管,需要每天把公司伺服器開放連接埠掃描記錄,一旦出現增加減少能發現。之前使用shell寫過一個https://github.com/bashhu/monitor-shell/blob/master/python-script/scan_port.sh 最近打算完善一下我們的營運平台,
Time of Update: 2016-12-17
標籤:處理 智能提示 高亮 無法 pycharm 資料 跳轉 適合 googl Python是一種什麼語言?Python是一種電腦程式設計語言。你可能已經聽說過很多種流行的程式設計語言,比如非常
Time of Update: 2016-12-17
標籤:sys 無法 python 程式 encoding types ges style sci 在運行scrapy爬蟲程式的時候出現UnicodeDecodeError貼上錯誤原因與註冊表有關
Time of Update: 2016-12-17
標籤:image 命令列 nbsp auto font 情況 實用 height 表情 問題:如何查看某個類的方法文檔說明或者是函數的參數列表情況? 答: 方法一:直接在需要查詢的方
Time of Update: 2016-12-17
標籤:編寫 object print false traceback 第二版 ini source 長度 您可能聽說過,帶有 yield 的函數在 Python 中被稱之為 generator(
Time of Update: 2016-12-17
標籤:也會 其他 垃圾 這一 計數 執行 介紹 images alt python對象銷毀(記憶體回收):1>同Java語言一樣,python使用了引用
Time of Update: 2016-12-17
標籤:down erro pack 添加 ade error ted 許可權 win32 遇到的倆種錯誤1.ValueError: zlib is required unless
Time of Update: 2016-12-17
標籤:err pac root package ase epel ror python 解決 root使用者使用yum install -y python-pip 時會報如下錯誤: No
Time of Update: 2016-12-17
標籤:傳遞 函數 影響 分享 技術分享 image 記憶體 修改 img 1、淺拷貝1>賦值:從下面的例子我們可以看到賦值之後新變數的記憶體位址並沒有發生任何變化,實際上python中的賦
Time of Update: 2016-12-17
標籤:entity new t 意義 並且 abstract nal 部分 lis 建立 1、節選自Python Documentation 3.5.2的部分解釋Objects are
Time of Update: 2016-12-17
1.簡單的將日誌列印到螢幕import logginglogging.debug('This is debug message')logging.info('This is info message')logging.warning('This is warning message') 螢幕上列印:WARNING:root:This is warning
Time of Update: 2016-12-17
一、hashlib概述涉及Data Encryption Service:14. Cryptographic Services其中 hashlib是涉及安全散列和訊息摘要,提供多個不同的密碼編譯演算法借口,如SHA1、SHA224、SHA256、SHA384、SHA512、md5等。import hashlibm = hashlib.md5() #建立hash對象,md5:(message-Digest Algorithm 5)訊息摘要演算法,得出一個128位的密文PRint m
Time of Update: 2016-12-17
在C/C++中嵌入Python也比較簡單,首先需要在VC中添加Python的include檔案目錄和lib檔案目錄:VC6.0下,開啟 tools->options->directories->show directories for,將Python安裝目錄下的inlude目錄添加到inlude files項中,將libs目錄添加到library
Time of Update: 2016-12-17
1.常用異常名 AttributeError 調用不存在的方法引發的異常。EOFError 遇到檔案末尾引發的異常。ImportError 匯入模組出錯引發的異常。IndexError 列表越界引發的異常。IOError I/O操作引發的異常,如開啟檔案出錯等。KeyError 使用字典中不存在的關鍵字引發的異常。NameError 使用不存在的變數名引發的異常。TabError 語句塊縮排不正確引發的異常。ValueError
Time of Update: 2016-12-17
欄位類型(Field types)AutoField它是一個根據 ID 自增長的 IntegerField 欄位。通常,你不必直接使用該欄位。如果你沒在別的欄位上指定主 鍵,Django 就會自動添加主鍵欄位。BigIntegerField64位整數,類似於IntegerField,範圍從-9223372036854775808 到9223372036854775807。預設的form widget
Time of Update: 2016-12-17
建立一個簡易Modelclass Person(models.Model): GENDER_CHOICES=( (1,'Male'), (2,'Female'), ) name=models.CharField(max_length=30,unique=True,verbose_name='姓 名')
Time of Update: 2016-12-17
關聯關係欄位 (Relationship fields)ForeignKey,ManyToManyField與OneToOneField分別在Model中定義多對一,多對多,一對一關聯性。例如,一本書由一家出版社出版,一家出版社可以出版很多書。一本書由多個作者合寫,一個作者可以寫很多書。class Author(models.Model): name=models.CharField(max_length=20)class Publisher(models.Model): name=
Time of Update: 2016-12-17
1. 一個列表實現兩個棧class Twostacks(object): def __init__(self): self.stack=[] self.a_size=0 self.b_size=0 self.top=0 def a_isEmpty(self): return self.a_size==0 def a_push(self,item): self.stack.insert(self.
Time of Update: 2016-12-17
1. 棧棧(Stack)是限制插入和刪除操作只能在一個位置進行的表,該位置是表的末端,稱為棧的頂(top)。棧的基本操作有PUSH(入棧)和POP(出棧)。棧又被稱為LIFO(後入先出)表。1.1 棧的實現class Stack(object): def __init__(self): self.stack=[] def isEmpty(self): return self.stack==[] def push(self,item):