Time of Update: 2018-07-31
這兩天學習Python一些應用教程的時候,看到這種寫法: return series.apply(lambda x:((x - min_val) / scale) - 1.0) lambda是什麼東西。。。。。沒見過,於是search online,大致是說lambda是一個匿名函數,用於解決簡單函數的命名問題,通俗一點說,比如你在程式中想寫這樣一個函數 def a(x): x = x + 1 return xprint(a(2))
Time of Update: 2018-07-30
用遞迴的記憶化搜尋枚舉出n組括弧的情況 class Solution(object): dp=[] def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ while(n>=len(self.dp)):self.dp.append(-1)
Time of Update: 2018-07-31
最近學了下smtplib模組,然後自己寫了一個用來發送郵件的代碼,在Windows下運行是沒有問題的,但是放到伺服器上運行後,卻一直沒有運行。 一開始是這麼寫的: 但是運行後就一直卡在這裡: 背景進程也有: 然後去百度,試了很多種方法,最後解決了,解決方案如下: 我把原始碼修改成了如下的格式: 然後我們再次運行,可以看到,已經運行成功了: 這時郵箱的提醒也來了: 發生該問題的原因如下:
Time of Update: 2018-07-30
python dict按照key 排序: 1、method 1. items = dict .items() items.sort()
Time of Update: 2018-07-31
執行個體1: 點擊(此處)摺疊或開啟 #!/usr/bin/env python import subprocess import datetime import re import sys import os res = subprocess.Popen("id root",stdout=subprocess.PIPE,shell=True)
Time of Update: 2018-07-31
如果路過的朋友們發現錯誤或有意見,歡迎指正和提出。當然,對一些題目沒頭緒時,會參考一下前輩們的代碼,在此表示感謝。 第5章 5-4 #!/usr/bin/env python#coding:utf-8year = int(raw_input('請輸入年份:'))if (year % 4==0 and year % 100!=0) or (year % 400==0) : print '%d是閏年' % yearelse :
Time of Update: 2018-07-31
滲透測試中,經常遇到無法使用wireshark、無法嗅探和分析流量的情況,可以通過部署簡單的TCP代理指令碼來瞭解未知的協議,修改資料包,或者為模糊測試建立環境。 介紹 原理 代理工作原理大致如下: [需要代理方]向伺服器發出請求資訊。 [代理方]應答。 [需要代理方]接到應答後發送向[代理方]發送目的ip和連接埠。 [代理方]與目的串連。 [代理方]將[需要代理方]發出的資訊傳到目的方,將目的方發出的資訊傳到[需要代理方]。
Time of Update: 2018-07-31
在WX中通常會用到StaticText和TextCtrl來顯示字元。類似於MFC中的 Static 和 Edit。TextCtrl可以設定更多屬性,但是他有邊框,有底色。 他們的預設顯示效果,如下圖: code如下: import wxclass MainFrame(wx.Frame): def __init__(self, iid=-1, redirect=True, parent=None, pos=wx.DefaultPosition, title='RCL
Time of Update: 2018-07-31
我只是個python初 學者..... 想用python做一個很簡單的內送郵件的功能,只看python的官方doc(http://docs.python.org/2/library/imaplib.html)真的很不好懂,經過google之,探索之,稍微總結一下: 要使用imap內送郵件,當然要匯入imaplib拉. import imaplib 然後按常規的,建立連結→登入 conn = imaplib.IMAP4("imap.xxx.
Time of Update: 2018-07-31
前言 沒有用過的東西,沒有深刻理解的東西很難說自己會,而且被別人一問必然破綻百出。雖然之前有接觸過python協程的概念,但是只是走馬觀花,這兩天的一次交談中,別人問到了協程,頓時語塞,死活想不起來曾經看過的東西,之後突然想到了yield,但為時已晚,只能說概念不清,所以本篇先縷縷python的產生器和yield關鍵字。 什麼是產生器 產生器是一個特殊的程式,可以被用作控制迴圈的迭代行為 產生器類似於傳回值為數組的一個函數,
Time of Update: 2018-07-31
http://blog.csdn.net/hushiwen/article/details/8531302 具體就是setattr, __setattr__, __dict__等的用法,具體可以看python的手冊了,舉剛剛寫的一小段代碼為例。 class Foo: pass def test(self): print "hello" def test1(): print "hello1
Time of Update: 2018-07-31
python運行時環境: python的運行時最初在python解譯器啟動的時候建立。 建立過程:(1)建立主進程對象(PyInterpreterState)
Time of Update: 2018-07-31
原文連結:http://legacy.python.org/dev/peps/pep-0008/ item detail PEP 8 Title Style Guide for Python Code Version c451868df657 Last-Modified 2016
Time of Update: 2018-07-31
1、pandas.read_csv()函數,讀取檔案資料時,由於分隔字元為'::',彈出如下警告 警告:ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are
Time of Update: 2018-07-31
今天沒事兒完了一下菜鳥教程的python編譯器發現挺有意思,想搞明白它的原理是啥,於是我輸入了以下代碼: import sys,osprint(sys.version_info)print(sys.executable)print(sys.path[0])print(os.listdir(sys.path[0]))with open("/usercode/file.py") as e:print(e.read())結果是這樣的:
Time of Update: 2018-07-30
標籤:語言 程式碼 內容 進位 列表 轉換 bsp div 十進位 注釋分類單行注釋多行注釋作用使用自己熟悉的語言,在程式中對某些代碼進行標註說明,增強程式可讀性單行注釋(行注釋)以 # 開頭,
Time of Update: 2018-07-30
標籤:com tom 也有 blog install tracking ofo 原因 第三方 國內的pythoner強烈建議使用豆瓣的pypi源雖然用easy_install和pip
Time of Update: 2018-07-30
標籤:arc mys enc userinfo 提高 info gate mode wro web架構Web架構(Web
Time of Update: 2018-07-30
標籤:分享 strong bubuko sof image replace 轉換 格式 ros python基礎資料型別 (Elementary Data Type) int
Time of Update: 2018-07-30
標籤:print 優先 也會 port epc 深淺拷貝 style 列表 記憶體 一:淺拷貝import copyl1 = [1, 2, 3, [4, 5, 6]]l2 =