首页
学习
活动
专区
工具
TVP
发布

sktj

专栏作者
1542
文章
1891254
阅读量
34
订阅数
python 访问需要用户名密码的URL脚本
import urllib.request,urllib.error,urllib.parse
用户5760343
2022-05-14
8280
python核心编程(数据库)
Cursor类的方法:rawcount,callproc,execute,fetchone
用户5760343
2022-05-14
6780
Django2.0中文(部署)
1、settings.py中DEBUG=False/TEMPLATE_DEBUG=False 2、vi xx/templates/404.html vi xx/templates/500.html 3、settings.py 中 ADMIN设置错误警告的用户,还包括EMAIL_HOST/EMAIL_HOST_USER,EMAIL_HOST_PASSWORD,EMAIL_PORT EMAIL_SUBJECT_PREFIX可以设置成前缀[Django] 4、连接中断邮件告警:MANAGERS 5、在manage.py中可以更改settings的路径 6、使用APACHE和mod_python部署: LoadModule python_module /usr/lib/apache2/modules/mod_python.so <Location "/"> SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug Off </Location>
用户5760343
2022-05-14
2210
Django2.0中文(通用视图)
1、通用视图 urls.py: from django.views.generic import TemplateView path(r'about/',TemplateView.as_view(template_name="about.html")), 2、通用视图 about.html xx/templates/about.html
用户5760343
2022-05-14
6950
python查找页面元素脚本
import urllib.request def gethtml(url='http://www.baidu.com'):
用户5760343
2022-05-14
1.2K0
python打印和下载页面 脚本
import urllib.request def gethtml(url='http://www.baidu.com')
用户5760343
2022-05-14
6890
python 多线程socket
import socketserver, time # get socket server, handler objects myHost = '' # server machine, '' means local host myPort = 50007 # listen on a non-reserved port number def now(): return time.ctime(time.time())
用户5760343
2022-05-13
2810
python signal捕捉信号 脚本
def onSignal(signum, stackframe): # Python signal handler print('Got signal', signum, 'at', now()) # most handlers stay in effect if signum == signal.SIGCHLD: # but sigchld handler is not print('sigchld caught') #signal.signal(signal.SIGCHLD, onSignal)
用户5760343
2022-05-13
1.2K0
python pyqt5 QListView
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QListView, QMessageBox from PyQt5.QtCore import QStringListModel import sys
用户5760343
2022-01-10
7510
python 函数回调
def apply_async(func, args, , callback): # Compute the result result = func(args)
用户5760343
2019-10-21
8340
jquery 表单验证
("form :input.required").each(function(){
用户5760343
2019-10-10
3.5K0
flask 扩展开发(flask 113)
Flask,一个微框架,通常需要一些重复的步骤来让第三方库工作。因为在很多时候, 这些步骤可以被分离出,来支持多个项目,就有了 Flask Extension Registry 。
用户5760343
2019-08-20
4740
flask 配置文件settings.py(flask 44)
basedir=os.path.abspath(os.path.dirname(file))
用户5760343
2019-08-15
1K0
flask app从py文件加载配置文件(flask 34)
WIN = sys.platform.startswith('win') if WIN: prefix = 'sqlite:///' else: prefix = 'sqlite:////'
用户5760343
2019-08-13
1.7K1
flask 数据库配置(flask 25)
from flask_sqlalchemy import SQLAlchemy WIN = sys.platform.startswith('win') if WIN: prefix = 'sqlite:///' else: prefix = 'sqlite:////' app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL', prefix + os.path.join(app.root_path, 'data.db'))
用户5760343
2019-08-13
6580
IOS 使用Text Kit编排图文
1 let textView = UITextView(frame:CGRect(x:20, y: 40, width:280, height:500)) 2 textView.backgroundColor = UIColor.brown 3 self.view.addSubview(textView) 4 5 let textStorage = textView.textStorage 6 let path = Bundle.main.url(forResource:“word”, withExtension:“txt”) 7 do { 8 let string = try String(contentsOf:path!) 9 textStorage.replaceCharacters(in:NSRange(location: 0,length:0), with:string) 10 } 11 catch{ 12 print(“读取文件错误!”) 13 } 14 let image = UIImage(named:“Tea”) 15 let imageView = UIImageView(image:image) 16 let rect = CGRect(x:80, y:80, width:150, height:
用户5760343
2019-07-10
4420
IOS 使用Text Kit做排版
1 let firstTextView = UITextView(frame:CGRect(x:20, y:40, width:135, height:200)) 2 firstTextView.backgroundColor = UIColor.brown 3 firstTextView.isScrollEnabled = false; 4 self.view.addSubview(firstTextView) 5 let textStorage = firstTextView.textStorage 6 let path = Bundle.main.url(forResource:“word”, withExtension:“txt”) 7 do { 8 let string = try String(contentsOf:path!) 9 textStorage.replaceCharacters(in:NSRange(location: 0,length:0), with:string) 10 } 11 catch{ 12 print(“读取文件错误!”) 13 } 14 let secondRect = CGRect(x:165, y:40, width:135, height:200) 15 let secondTextContainer = NSTextContainer() 16 let secondTextView = UITextView(frame:secondRect, textContainer:secondTextContainer) 17 secondTextView.backgroundColor = UIColor.brown 18 secondTextView.isScrollEnabled = false; 19 self.view.addSubview(secondTextView) 20 let thirdRect = CGRect(x:20, y:250, width:280, height:300) 21 let thirdTextContainer = NSTextContainer() 22 let thirdTextView = UITextView(frame:thirdRect, textContainer:thirdTextContainer) 23 thirdTextView.backgroundColor = UIColor.purple 24 thirdTextView.isScrollEnabled = false; 25 self.view.addSubview(thirdTextView) 26 let layoutManager = NSLayoutManager() 27 layoutManager.addTextContainer(firstTextView.textContainer) 28 layoutManager.addTextContainer(secondTextContainer) 29 layoutManager.addTextContainer(thirdTextContainer) 30 textStorage.addLayoutManager(layoutManager)
用户5760343
2019-07-10
4020
IOS UIRefreshControl刷新控件
import UIKit class ViewController:UIViewController,UITableViewDelegate,UITableViewDataSource{ @IBOutlet weak var tabvLayout:UITableView! var refreshControl = UIRefreshControl() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.automaticallyAdjustsScrollViewInsets = false //添加刷新 refreshControl.addTarget(self, action:#selector(refreshData), for: UIControlEvents.valueChanged) refreshControl.attributedTitle =NSAttributedString(string:”松开后自动刷新”) tabvLayout.addSubview(refreshControl) refreshData() } // 刷新数据 func refreshData() { self.tabvLayout.reloadData() self.refreshControl.endRefreshing() } // MARK:- UITableViewDataSource func tableView(_ tableView:UITableView,numberOfRowsInSection section:Int) -> Int { return 10; } func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath) -> UITableViewCell { let cell = UITableViewCell(style:UITableViewCellStyle.value1, reuseIdentifier:“newsCell”) let date = NSDate() let timeFormatter = DateFormatter() timeFormatter.dateFormat = “yyy-MM-dd ‘at’ HH:mm:ss.SSS” //(时间格式) let strNowTime = timeFormatter.string(from:date as Date) as String cell.textLabel?.text = strNowTime let rect = CGRect(x:0,y:cell.frame.height-1,width:self.view.frame.size.width,height:1) let label = UILabel(frame:rect) label.backgroundColor = UIColor.lightGray() cell .addSubview(label) return cell; } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
用户5760343
2019-07-08
6870
IOS UITableView UITableViewCell控件
import UIKit class ViewController:UIViewController,UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. let screenRect = UIScreen.main.bounds let tableRect = CGRect(x:0, y:20, width: screenRect.size.width, height:screenRect.size.height - 20) let tableView = UITableView(frame:tableRect) tableView.dataSource = self self.view.addSubview(tableView) } func tableView(_ tableView:UITableView,numberOfRowsInSection section:Int) -> Int{ return 20 } func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath) -> UITableViewCell { let identifier = “reusedCell” var cell =tableView.dequeueReusableCell(withIdentifier:identifier) if(cell == nil) { cell = UITableViewCell(style:UITableViewCellStyle.default, reuseIdentifier:identifier) } cell?.textLabel?.text = “命运负责洗牌,玩牌的是我们自己!” return cell! } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
用户5760343
2019-07-08
6230
没有更多了
社区活动
腾讯技术创作狂欢月
“码”上创作 21 天,分 10000 元奖品池!
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档