随笔分类 - Python
摘要:1.使用qt designer设计界面,保存为test1.ui: 2.使用pyuic4 test1.ui -o ui.py生成ui代码。 3.程序载入。 结果: 修改后:
阅读全文
摘要:import sys from PyQt4 import QtCore, QtGui app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() widget.resize(600, 400) edit = QtGui.QTextEdit() btn1=QtGui.QPushButton("button1") btn2=QtGui...
阅读全文
摘要:import sys from PyQt4 import QtCore, QtGui class myWidget(QtGui.QWidget): def __init__(self): super(myWidget, self).__init__() self.setWindowTitle("test") self.resize(30...
阅读全文
摘要:环境:windows7+python2.7+PyQt4
阅读全文
摘要:from HTMLParser import HTMLParserimport sysclass TitleParser(HTMLParser): def __init__(self): self.title = '' self.readingtitle=0 HTMLParser.__init__(self) def handle_starttag(self, tag, attrs): if tag == 'title': self.readingtitle=1 def handle_data(se...
阅读全文
摘要:import os,sys, urllib2req=urllib2.Request(sys.argv[1])fd=urllib2.urlopen(req)file=open('123.html','w')while 1: data=fd.read(1024) if not len(data): break #sys.stdout.write(data) file.write(data)file.close()
阅读全文
摘要:import osfile=open("123.txt","r")for line in file.readlines(): print line,file.close()file=open("123.txt","w")file.write("sdfsdfsdf")file.close()file=open("123.txt","a")file.write("erertyerty")file.close()file=open("
阅读全文
摘要:import mathprint 12*34+78-132/6print (12*(34+78)-132)/6print (86/40)**5print math.fmod(145,23)print math.sin(0.5)print math.cos(0.5)a=1+2c=4print "1+2=%d" %aprint "1+2=%d,%d" %(a,c)
阅读全文
摘要:import time#n=input("input a year:")n=time.localtime()[1]'''if n%400==0 or (n%4==0 and n%100!=0): print "yes"else: print "not"'''print n
阅读全文

浙公网安备 33010602011771号