Python 3 中檢測QQ線上的指令碼
近期在學習python ,在論壇上看到一些qq 狀態的測試,但都是python 2.7的版本,為此在python3 中實現一次,以便日後複習使用
import time,datetime
from urllib.request import urlopen
def chk_qq(qqnum):
chkurl = 'http://wpa.qq.com/pa?p=1:'+str(qqnum)+':1'
print(chkurl)
a = urlopen(chkurl)
length=a.headers.get("content-length")
a.close()
print (datetime.datetime.now() )
if length=='2329':
return 'Online'
elif length=='2262':
return 'Offline'
else:
return 'Unknown Status!'
qq = 595787398
stat = chk_qq(qq)
print (str(qq) + ' is ' + stat)
相關推薦
Python 3 中檢測QQ線上的指令碼
近期在學習python ,在論壇上看到一些qq 狀態的測試,但都是python 2.7的版本,為此在python3 中實現一次,以便日後複習使用 import time,datetime from urllib.request import urlopen def chk
Python自學之樂-python 2、python 3中經典類、新式類的深度和廣度優先小結
python2 __init__ 寫上 print class ast python init 廣度優先 #Author:clarkclass Original(object):#在python 3 中寫上object的新式類和不寫的經典類遵循的都是廣度優先原則 de
Python 3中的str和bytes類型
等等 nco sci 空間 英語單詞 轉換 代碼 strong odi Python3 中的str和bytes類型 Python3最重要的新特性之一是:對字符串和二進制數據流做了明確的區分。文本總是Unicode,由str類型表示,二進制數據則由bytes類型表示。Pyth
Python 3中bytes/string的區別
如何 strings 插入圖片 enc 混合 技術分享 cnblogs 劃分 比特 原文: https://www.cnblogs.com/abclife/p/7445222.html python 3中最重要的新特性可能就是將文本(text)和二進制數據做了更清晰的區分。
python 3中\w+匹配漢字的問題。
今天記錄一下有關python 3中正則表示式的一個小問題。 我們知道正常情況下,\w+匹配字母數字及下劃線,相當於[A-Za-z0-9_]。 在python 3中我們試下\w+的匹配字串的時候,會發現匹配會匹配到中文漢字。如下圖所示: 這是
python 3中 的subprocess
commands好像python3.6被去除了,它現在被subprocess替代了 FUNCTIONS getoutput(cmd) Return output (stdout or stderr) of executing cmd in a shell. getst
Python 3中的yield from語法詳解
前言 最近在搗鼓Autobahn,它有給出個例子是基於asyncio 的,想著說放到pypy3上跑跑看竟然就……失敗了。 pip install asyncio直接報invalid syntax,粗看還以為2to3處理的時 候有問題——這不能怪我,好~多package都是用
Python 3中實現cmp()函式的功能
本文由荒原之夢原創,原文連結:http://zhaokaifeng.com/?p=1088 cmp() 函式是Python 2中的一個用於比較兩個列表, 數字或字串等的大小關係的函式, 在Python 3中已經無法使用這個函數了: >>> a = [1, 2,
python 3 中的輸入和輸出問題
一、普遍的輸入和輸出 1.輸入 在python3中,函式的輸入格式為:input(),能夠接受一個標準輸入資料,返回string型別。 input() 函式是從鍵盤作為字串讀取資料,不論是否使用引號(”或“”)。 Name=input("請輸入你的名字:") prin
Python 3 中字符串和 bytes 的區別
binary 代碼 tin warning red all 進制 存儲 ipython 來自猿人學Python教程的學習筆記。 https://www.yuanrenxue.com/ 在Python中字符串和unicode真是傻傻分不清楚,在沒搞懂兩個區別時,你會發現程序報
Python 3 中字串和 bytes 的區別
來自猿人學Python教程的學習筆記。 https://www.yuanrenxue.com/ 在Python中字串和unicode真是傻傻分不清楚,在沒搞懂兩個區別時,你會發現程式報的錯怎麼改都是再報錯,讓你煩躁。 學習Python的時候,又重溫了這部分內容,寫了這個學習筆記。 &nbs
python 3 12306餘票查詢指令碼
原文地址 https://blog.csdn.net/memory_qianxiao/article/details/81944732 直接帖程式碼,不懂的看原文,只是注意下url地址更新了,原來那個地址好像訪問不了,然後加上了時間輸入 #-*- coding:utf-8 -*- import
Python 3 中的 urllib 例項
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import time import sys import gzip import socket import urllib.request, urllib.parse, urllib.error import
python 3 中的time模組使用(待完善)
python中和時間處理有關的模組包括time,datetime,calender等模組: python通常用這幾種方式來表示時間:1)時間戳,2)格式化的字串,3)元祖struct_time中含有九個元素,分別表示的就是年月日等資訊 time模組中包含的某些函式: tim
在網頁中 生成QQ線上臨時對話方塊/聊天
2)在“頁面設定”中選擇“設定部落格首頁模版”,在其中“自定義內容元件”內選擇“新增文字元件”下面是我已經設定好了的三個元件的效果圖,未設定之前這裡是空白的,您可以通過自定義元件新增文字元件任意新增自己喜歡的內容、公告資訊、個人介紹、插入圖片或其它多媒體檔案;
在Python 3中設定Jupyter Notebook
介紹Jupyter Notebook提供了一個用於作為Web應用程式的互動式計算的命令shell。該工具可以與多種語言一起使用,包括Python,Julia,R,Haskell和Ruby。它通常用於處理資料,統計建模和機器學習。 本教程將引導您設定Jupyter Notebo
pickle 在python 2和python 3中相容性問題
以下的演示均在python 3環境下進行。 我們以一個簡單的檔案開啟和檔案讀為例說明,pickle讀檔案時可能存在的編碼問題: import gzip import pickle # 使用with結構避免手動的檔案關閉操作 with gzip.
Shell中檢測某一網段IP線上與否的指令碼
作為系統管理員或者執行維護人員,經常會碰到檢查某個網段IP是up還是down的情況,這個時候肯定不會一個個手工去ping的,寫指令碼是肯定的,小指令碼其實很簡單 #!/bin/bash set -xv ip1='192.168.0' for ip2 in $(seq 0 254) do
[windows]如何在batch指令碼中檢測系統是否安裝了python和pip
手頭的一個專案需要為使用者的windows機器配置python環境,需要安裝python和pip(python的包管理工具),當然,已經安裝過的使用者就不需要重灌了,那麼問題來了,如何檢測使用者的windows系統已經安裝了python和pip呢?除錯了一個上午,終於找到一
Python 3 利用 Dlib 19.7 實現攝像頭人臉檢測特征點標定
backend 開發 img com inter 適合 github red for 0.引言 利用python開發,借助Dlib庫捕獲攝像頭中的人臉,進行實時特征點標定; 圖1 工程效果示例(gif) 圖2 工程效果示例(靜態