hysyeah

知易行难


  • 首页

  • 分类

  • 标签

  • 归档

  • 关于

  • 搜索

docker常用命令

发表于 2017-09-25 分类于 未分类

-docker安装[通过脚本安装] curl -sSL https://get.daocloud.io/docker | sh -常用命令 sudo apt-get update sudo systemctl enable docker sudo systemctl start docker # ...

阅读全文 »

ubuntu安装五笔

发表于 2017-09-22 分类于 Linux

1.sudo apt-get install ibus-table-wubi 2.reboot 3.Text Entry添加输入法

阅读全文 »

lua -e

发表于 2017-09-22 分类于 LUA

lua -e "print("hello")" --ouput nil lua -e "print("1")" -- output 1 为什么lua -e “print(“hello”)”输出来nil, 而不是hell ...

阅读全文 »

lua求阶乘发生溢出

发表于 2017-09-21 分类于 LUA

function fact(n) if n == 0 then return 1 end return n * fact(n-1) end for i=1, 100, 1 do print(i,fact(i)) --发生溢出 end 通过使用lua的’bn’库可以解决这问 ...

阅读全文 »

python魔法变量之__getattribute__,__getattr__

发表于 2017-09-20 分类于 未分类

object.getattribute(self, name) 无条件调用,通过实例访问。如果类同时定义了getattr(),不会调用getattr()除非显式调用或产生了AttributeError。 object.getattr(self, name) 当未查找到访问的属性时,将会调用getat ...

阅读全文 »

python魔法变量之__class__,__bases__,__mro__

发表于 2017-09-20 分类于 python

bases:一个类的基类 In [4]: class B: ...: pass ...: In [5]: class A(B): ...: pass ...: In [6]: A.__bases__ Out[6]: (<class __main_ ...

阅读全文 »

mysql-UNION与UNION ALL

发表于 2017-09-19 分类于 数据库

SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | DISTINCT] SELECT ...] UNION用于将多个SELECT语句的结果整合并放在一个表中,并消除重复的行,UNION ALL并不会消除重复的行 mysql>&g ...

阅读全文 »

wordpress屏蔽更新提示

发表于 2017-09-15 分类于 未分类

wordpress/wp-includes/update.php 在最后面添加 add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); ...

阅读全文 »

Django为已有的数据库生成model

发表于 2017-09-15 分类于 Django

python manage.py inspectdb # 将settings.py中DATABASES中指定的数据库的所表的model导入到models.py中 python manage.py inspectdb > models.py # 也可以指定数据表 python mana ...

阅读全文 »

pip使用豆瓣源

发表于 2017-09-15 分类于 未分类

将pip源修改为豆瓣源 vim ~/.pip/pip.conf 没有则新建 添加如下内容: [global] index-url = http://pypi.douban.com/simple --trusted-host = pypi.douban.com 2.临时更换 sudo pip ins ...

阅读全文 »

mysql的limit,offset分页

发表于 2017-09-15 分类于 数据库

1.SELECT * FROM br_apply_check_info LIMIT 20 OFFSET 612000; --0.769s 2.SELECT * FROM br_apply_check_info INNER JOIN (SELECT id from br_apply_check_in ...

阅读全文 »

定义一个可以通过属性访问的字典

发表于 2017-09-15 分类于 python

In [6]: class attrdict(dict): ...: def __getattr__(self, attr): ...: try: ...: return self[attr] ...: exce ...

阅读全文 »

python各时间段获取和时间类型的转换

发表于 2017-09-15 分类于 python , python标准库

python获取各时段起始时间和各种类型时间的相互转换In [1]: import datetime In [2]: from datetime import timedelta 1.获取今天时间 In [3]: now = datetime.datetime.now() In [4]: now ...

阅读全文 »

python魔法变量之__slots__

发表于 2017-09-08 分类于 python

slots变量,用来限制类能添加的属性。由于’score’没有被放到slots中,所以不能绑定score属性,所以报错。 使用slots要注意,slots定义的属性仅对当前类起作用,对继承的子类是不起作用的: 除非在子类中也定义slots这样,子类允许定义的属性就是自身的slots加上父类的slot ...

阅读全文 »

django添加自定义过滤器

发表于 2017-09-08 分类于 Django

1.在app目录下与models.py同级目录下新建一个templatetags文件夹, 2.utils.py from django import template register = template.Library() @register.filter def val_type(val ...

阅读全文 »

一行把tuple转换为list

发表于 2017-09-06 分类于 python

In [16]: tup = ((1, 2, 3), (4, 5, 6)) In [17]: list(map(list,tup)) Out[17]: [[1, 2, 3], [4, 5, 6]]

阅读全文 »

namedtuple映射名称到序列元素

发表于 2017-09-06 分类于 python标准库

In [1]: from collections import namedtuple In [2]: dt = namedtuple('s', ['name', 'job']) In [3]: ret = dt('hys',  ...

阅读全文 »

flatten

发表于 2017-09-05 分类于 python标准库

In [1]: from compiler.ast import flatten In [2]: flatten([1, [2], [3, [[4,]]]]) Out[2]: [1, 2, 3, 4] 源代码: def flatten(seq): l = [] for elt in ...

阅读全文 »

numpy数据类型基本操作

发表于 2017-09-05 分类于 python科学计算

1.导入numpy包,调用array()函数创建一维数组 In [3]: import numpy as np In [4]: a = np.array(range(6)) In [5]: a Out[5]: array([0, 1, 2, 3, 4, 5]) In [6]: print(a) ...

阅读全文 »

zeppelin创建mysql解析器,连接mysql

发表于 2017-09-04 分类于 python科学计算

zeppelin环境的配置 1.创建mysql解析器 2.根据上图填写配置 3.创建Note 4.编写sql语句,执行后生成下图 Ref: 1.https://zeppelin.apache.org/docs/0.7.0/interpreter/jdbc.html

阅读全文 »
1…151617

hys

329 日志
30 分类
35 标签
hysyeah.top © 2019-2025 粤ICP备19077752号