请转到www.cnblogs.com/iMath/

■■■■■■■■■■本博客打算放弃,请转到www.cnblogs.com/iMath/

Just put all files in a queue, and only allow a fixed number to run simultaniously

gets signalled when any of these finishes.


Windows 上面运行python3命令

http://stackoverflow.com/questions/18058389/how-to-switch-between-python-2-7-to-python-3-from-command-line

Python的time module里的两个函数

>>> from time import *

>>> strftime("%H:%M:%S", localtime())

'19:43:19'

>>> time() 

1479123830.3926537

>>> int(time())

1479123934


Get m3u8 playlist urls by Python

The most frequently usage for you to use this m3u8 module is perhaps you want to get the playlist URLs, here is the fast way, for example


>>> import m3u8

>>> m3u8.load('https://www.the5fire.com/static/demos/diaosi.m3u8').files

['http://123.125.123.82/ipad?file=/81/70/OitlPYGCUGyq6AEJl75wm5...

Collecting Parameters and Distribute Parameters

################################   *   ###############################

The star in front of the parameter puts all the values into the same tuple. 

def print_params_2(title, *params):

    print title

    print params


>>...

File extensions in Web-page URLs should be avoided

File extensions in Web-page URLs should be avoided.


Technically, foo.com/bar and foo.com/bar/ are two different URLs


https://www.w3.org/Provider/Style/URI

Python Unable to find vcvarsall.bat

Simply try

python setup.py build --compiler=“c:\programs\MinGW\bin”install


or


  1. Add mingw32's bin directory to your environment variable: append c:\programs\MinGW\bin; to the PATH

  2. python setup.py build -c mingw32 install


Implemente Euler's Method via Python

to solve this question


def f(n):

    stepSize = 1 / 2

    if n == 0:

        return 2

    else:

        v = n - stepSize

        new_value =...

Generate Fibonacci sequence via Python

Basic implementation

http://openbookproject.net/thinkcs/python/english3e/recursion.html#case-study-fibonacci-numbers

optimized

http://openbookproject.net/thinkcs/python/english3e/dictionaries.html#memoization


alreadyknown = {0: 0, 1: 1}


def fib(n):

    if n not in alreadyknown...

Get file extension(suffix) from URL by Python

获取url里的文件扩展名


>>> import urllib.parse,os

>>> url="http://220.165.10.15/videos/v0/20140815/3d/62/77772ee94ed4c3b6d265bca9f5d576cd.f4v?key=0dcb341c18a4b6f8f246841ad03aced98&src=iqiyi.com&su=a9c60180dc324addb9501c8f4d7606d7&qyid=6ab810a4f36c4c4a96acd32d86dc52a4&...

ubuntu 上使用PyQt5的一些问题解决方案

1.安装PyQt5 5.4.1


基于Ubuntu系统的用户可以按下面的步骤来安装


将源换为Ubuntu 15.04(Vivid Vervet)的


sudo gedit /etc/apt/sources.list


http://www.linuxdiyf.com/viewarticle.php?id=422624


sudo apt-get update


如果换源让你不舒服,那么您可以在安装完本软...

Sublime Python 开发

http://www.sublimetext.com/3


安装的时候勾选加入Python环境变量,否则手动加入 C:\Python34;  即可


配置命令的时候单词一律小写

Preferences > Key Bindings - User

[


 { "keys": ["f1"], "command": "build" },

{"keys": ["escape...

用PyQt4将图像灰度化(convert a color image to a grayscale

from PyQt4.QtCore import * from PyQt4.QtGui import * import sys import time app = QApplication(sys.argv) img=QImage('画画.bmp') height=img.height() width=img.width() print(height, width) #p=img.pixel(1, 0) #print(qRed(p), qGreen(p), qBlue(p)) # #l=img.scanLine(0) #l.setsize(img.bytesPerLine()) # #v=memoryview...

QTableView去掉虚焦点线框/ remove dotted focus rectangle o

for  QStyledItemDelegate ,you could follow this post

http://qt-project.org/faq/answer/how_can_i_remove_the_dotted_rectangle_from_the_cell_that_has_focus_in_my_qt


for  QItemDelegate ,just

override the virtual drawFocus() function and let it do nothing

or this way

class NoRectDelegate...

python regex non -greedy

从第一个满足条件的起点到最近的结点为一次匹配

import re searchPattern = re.compile(r"a.+?b") downloadLinkList =searchPattern.findall('ababab') print(downloadLinkList)

import re, os htmlSrc=""" <p style="text-indent:5.25pt;"> <span><b><span style="font-family...

Django Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问

python manage.pyrunserver之后出现这个错误的一个可能原因是你的电脑正在运行的程序(比如酷狗)占用了8000端口,but by default, the runservercommand starts the development server on the internal IP at port 8000


解决方法有两个:

  1. 关闭占用了8000端口的软件(比如酷狗);
  2. 更改Django测试服务器的端口号,for example :

通过PyQt4&Python获取网页源代码

为什么要用通过PyQt4来做呢?

绝大多数情况下我还是推荐用Python来做,因为更简单。

但是对于某些出了点小问题的网页来说,这种方法更保险——主要体现在字符编码的判断上,另外它是异步的。


如果你用Python来解析网页的话,首先你得判断网页的编码类型,除非你自己来判断,如果你通过chardet 或利用beautiful soup代为判断的话,那么对于这个出了点小问题的这个网页


http://www.qnwz.cn/html/yinlegushihui/magazine/2013/0524/425731.html


它们就会把字符编...

eric5 unhandled ImportErro: No module named icon_r

eric5 unhandled ImportErro: No module named icon_rc

in order to set the window icon ,I used resourcefiles ,then this error occurred when run the project through the main script ,whythis error and how to fix it ?

my project diagram structure is like this


this is because...

The PyQt4 code porting of Model/View Programming e

import sys from PyQt4.QtGui import * from PyQt4.QtCore import * if __name__ == '__main__': app =QApplication(sys.argv) splitter =QSplitter() model= QFileSystemModel () model.setRootPath(QDir.currentPath()) tree = QTreeView(splitter); tree.setModel(model); tree.setRootIndex(model.index(QDir.currentPath...

The PyQt4 code porting of《C++ GUI Programming with

Chapter 14. Multithreading

eg1

import sys, time from PyQt4.QtCore import * from PyQt4.QtGui import * class Thread(QThread): def __init__(self ): QThread.__init__(self) self.stopped = False; def setMessage(self, message): self.messageS = message def stop(self): self.stopped = True; def run(self...

The PyQt4 code porting of Model/View Tutorial exam

The PyQt4 code porting of Model/View Tutorial examples in Qt4.8’s Reference Documentation


2.1 A Read Only Table


import sys from PyQt4.QtGui import * from PyQt4.QtCore import * class MyModel(QAbstractTableModel): def __init__(self, parent=None): super(MyModel, self).__init__...

python里的多个if条件句

python里的某个语句块有多个if条件句的时候,程序执行时会逐一执行每个满足条件的if语句。


def showMeY(i): if i ==3: print(3) i=4 if i != 3: print(4) print('showMeY--------------------') showMeY(3) def showMeX(i): if i ==3: print(3) i=4 else: print(4) print('showMeX--------------------') showMeX(3)


The PyQt4 code porting of 《Foundations of Qt Devel

Ch3

3-1

import sys from PyQt4.QtGui import * from PyQt4.QtCore import * if __name__ == '__main__': app =QApplication(sys.argv) dlg=QDialog () groupBox = QGroupBox( "Groupbox" ); label =QLabel( "Supercalifragilisticexpialidocious" ); lineEdit = QLineEdit() buttons =QDialogButtonBox...

Python批量删除空文件夹

import os for root, dirs, files in os.walk(r'E:\学习资料\编程语言\Python\py32\libvlc', topdown=False): if os.listdir(root)==[]: os.rmdir(root)

Tips for regular expression (Python )

'^' (Caret.) Matches the start of the string, and inMULTILINE mode also matches immediately after each newline.


>>> re.findall(r'^th[\w ]+', """

... This line is the first,

... another line,

... that line, it's the best

... """)

[]


行首没有r...

自己实现的Python差集运算代码

计算的是集合A减去集合B的差集


def search_binary(sequence, target): lb = 0 ub = len(sequence) while True: if lb == ub: # If region of interest (ROI) becomes empty return -1 # Next probe should be in the middle of the ROI mid_index = (lb + ub) // 2 # Fetch the item at that position item_at_mid = sequence[mid_index...
1 / 2

© 请转到www.cnblogs.com/iMath/ | Powered by LOFTER