首页 文章 精选 留言 我的

精选列表

搜索[SVG格式],共10000篇文章
优秀的个人博客,低调大师

推荐一个小而美的Python代码格式化工具

代码可读性是评判代码质量的标准之一,有一个衡量代码质量的标准是 Martin 提出的 “WFT” 定律,即每分钟爆出 “WTF” 的次数。你在读别人代码或者做 Code Review 的时候有没有 “WTF” 冲动呢? 为了帮助开发者统一代码风格,Python 社区提出了 PEP8 代码编码风格,它并没有强制要求大家必须遵循,Python 官方同时推出了一个检查代码风格是否符合 PEP8 的工具,名字也叫 pep8,后来被重命名为了pycodestyle。 看如下代码: import time, datetime class ListNode: def __init__(self, val): self.val = val self.next = None # in python ne

优秀的个人博客,低调大师

sklearn.feature_extraction.DictVectorizer将字典格式的数据转换为特征

class sklearn.feature_extraction. DictVectorizer ( dtype=<class ‘numpy.float64’> , separator=’=’ , sparse=True , sort=True ) Transforms lists of feature-value mappings to vectors. This transformer turns lists of mappings (dict-like objects ) of feature names to feature values into Numpy arrays or scipy. sparse matrices(稀疏矩阵) for use with scikit-learn estimators. When feature values are strings, this transformer will do a binary one-hot (aka one-of-K) coding: one boolean-valued feature is constructed for each of the possible string values that the feature can take on. For instance, a feature “f” that can take on the values “ham” and “spam” will become two features in the output, one signifying “f=ham”, the other “f=spam”. However, note that this transformer will only do a binary one-hot encoding when feature values are of type string. If categorical features are represented as numeric values such as int, the DictVectorizer can be followed by OneHotEncoder to complete binary one-hot encoding. Features that do not occur in a sample (mapping) will have a zero value in the resulting array/matrix. Read more in the User Guide . Parameters: dtype : callable, optional The type of feature values. Passed to Numpy array/scipy.sparse matrix constructors as the dtype argument. separator : string, optional Separator string used when constructing new features for one-hot coding. sparse : boolean, optional. Whether transform should produce scipy.sparse matrices. True by default. sort : boolean, optional. Whether feature_names_ and vocabulary_ should be sorted when fitting. True by default. Attributes: vocabulary_ : dict A dictionary mapping feature names to feature indices. feature_names_ : list A list of length n_features containing the feature names (e.g., “f=ham” and “f=spam”).

优秀的个人博客,低调大师

Python 发送图文格式的服务器性能报表邮件脚本(smtplib)

coding: utf-8 import smtplib from email.mime.multipart import MIMEMultipart #导入MIMEMultipart类 from email.mime.text import MIMEText #导入MIMEText类 from email.mime.image import MIMEImage #导入MIMEImage类 HOST = "smtp.gmail.com" #定义smtp主机 SUBJECT = u"业务性能数据报表" #定义邮件主题 TO = "testmail@qq.com" #定义邮件收件人 FROM = "mymail@gmail.com" #定义邮件发件人 def addimg(src,imgid): #添加图片函数,参数1:图片路径,参数2:图片id fp = open(src, 'rb') #打开文件 msgImage = MIMEImage(fp.read()) #创建MIMEImage对象,读取图片内容并作为参数 fp.close() #关闭文件 msgImage.add_header('Content-ID', imgid) #指定图片文件的Content-ID,<img> #标签src用到 return msgImage #返回msgImage对象 msg = MIMEMultipart('related') #创建MIMEMultipart对象,采用related定义内嵌资源 #的邮件体 msgtext = MIMEText(""" #创建一个MIMEText对象,HTML元素包括表格<table>及图片<img> <table width="600" border="0" cellspacing="0" cellpadding="4"> <tr bgcolor="#CECFAD" height="20" style="font-size:14px"> <td colspan=2>*官网性能数据 <a href="monitor.domain.com">更多>></a></td> </tr> <tr bgcolor="#EFEBDE" height="100" style="font-size:13px"> <td> <img src="cid:io"></td><td> <img src="cid:key_hit"></td> </tr> <tr bgcolor="#EFEBDE" height="100" style="font-size:13px"> <td> <img src="cid:men"></td><td> <img src="cid:swap"></td> </tr> </table>""","html","utf-8") #<img>标签的src属性是通过Content-ID来引用的 msg.attach(msgtext) #MIMEMultipart对象附加MIMEText的内容 msg.attach(addimg("img/bytes_io.png","io")) #使用MIMEMultipart对象附加MIMEImage #的内容 msg.attach(addimg("img/myisam_key_hit.png","key_hit")) msg.attach(addimg("img/os_mem.png","men")) msg.attach(addimg("img/os_swap.png","swap")) msg['Subject'] = SUBJECT #邮件主题 msg['From']=FROM #邮件发件人,邮件头部可见 msg['To']=TO #邮件收件人,邮件头部可见 try: server = smtplib.SMTP() #创建一个SMTP()对象 server.connect(HOST,"25") #通过connect方法连接smtp主机 server.starttls() #启动安全传输模式 server.login("mymail@gmail.com","mypassword") #邮箱账号登录校验 server.sendmail(FROM, TO, msg.as_string()) #邮件发送 server.quit() #断开smtp连接 print "邮件发送成功!" except Exception, e: print "失败:"+str(e)

优秀的个人博客,低调大师

Android系统如何录制屏幕(录制成mp4格式)

不管是教学,还是为了演示,如果能将Android手机(或平板)的屏幕录制成视频文件,那是一件非常酷的事(iOS8已经提供了这一功能,能通过OS X直接在Mac上录制iPad、iPhone的屏幕,windows没试过,不知可不可以)。不过以前的方法都是通过截屏录制的,效果极差。幸好Android4.4以上版本提供了这一功能。但无法在手机上直接启动,需要通过adb使用命令行启动。 大家可以进入shell。或干脆直接用adb shell执行命令。该命令是screenrecord,可以输入screenrecord --help,看看帮助,如下所示。 Usage: screenrecord [options] <filename> Android screenrecord v1.2. Records the device's display to a .mp4 file. Options: --size WIDTHxHEIGHT Set the video size, e.g. "1280x720". Default is the device's main display resolution (if supported), 1280x720 if not. For best results, use a size supported by the AVC encoder. --bit-rate RATE Set the video bit rate, in bits per second. Value may be specified as bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 4Mbps. --bugreport Add additional information, such as a timestamp overlay, that is helpful in videos captured to illustrate bugs. --time-limit TIME Set the maximum recording time, in seconds. Default / maximum is 180. --verbose Display interesting information on stdout. --help Show this message. Recording continues until Ctrl-C is hit or the time limit is reached. 从这些帮助信息可以了解到,screenrecord需要后面跟一个mp4文件名。最简单的形式如下: screenrecord /sdcard/game.mp4 但要注意,mp4要写入的目录必须是可写的。 输入完命令后,直接按回车,命令会被阻塞,默认什么都不会输出,这是正在录制呢。操作手机的所有画面都会被录制下来。如果要输出相应的信息,需要加--verbose命令行参数,加该命令行参数,整个录制过程可能会输出如下类似的信息。 Main display is 1080x1920 @60.00fps (orientation=0) Configuring recorder for 1080x1920 video/avc at 4.00Mbps Content area is 1080x1920 at offset x=0 y=0 ^CEncoder stopping; recorded 68 frames in 12 seconds Stopping encoder and muxer Executing: /system/bin/am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///sdcard/test.mp4 Broadcasting: Intent { act=android.intent.action.MEDIA_SCANNER_SCAN_FILE dat=file:///sdcard/test.mp4 } Broadcast completed: result=0 当然,可以跟很多选项,常用的就是--size(尺寸)、--bit-rate(比特率)和--time-limit(录制最大时间) 尺寸默认是当前手机屏幕分辨率、比特率是默认4Mbps、录制时间默认是3分钟(180秒) screenrecord --time-limit 100 /sdcard/game.mp4 上面的命令最大可录制100秒的视频。如果想中途停止录制,可按Ctrl C,终止录制,game.mp4仍然会生成,但只会录制从开始录制到按Ctrl-C这段时间的视频。下图是我录制的20秒射击游戏的效果图。完整视频可在下面的地址下载。 录制视频下载 本文转自银河使者博客园博客,原文链接http://www.cnblogs.com/nokiaguy/p/4132999.html如需转载请自行联系原作者 银河使者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册