line

python之函数

夙愿已清 提交于 2019-12-26 21:37:39
第一:函数的定义 使用函数的背景:   现在领导让你把公司加上机器的监控与报警信息做一下统计,防止遗漏监控,连接数据库代码: def get_host(): 创建数据库连接 通过cursor方法获取游标 通过execute对sql进行操作 关闭游标 def get_item(): 创建数据库连接 通过cursor方法获取游标 通过execute对sql进行操作 关闭游标 def get_tirggers(): 创建数据库连接 通过cursor方法获取游标 通过execute对sql进行操作 关闭游标 完全可以按照上面的方式操作数据库,但是这样写存在两个问题:   1.代码重复过多   2.如果日后要更改操作数据库,比较麻烦 def con_sql(sql): 创建数据库连接 通过cursor方法获取游标 通过execute对sql进行操作 关闭游标 def get_host(host): conn_sql(host) def get_item(item): conn_sql(item) def get_tirggers(triggers): conn_sql(triggers) 这样写可以体现出函数的好处:   1.解决了代码重用的问题   2.保持代码一致性,易维护   3.容易扩展 在此处提下函数式编程和面向过程编程的区别: 函数式:将某功能代码封装到函数中,日后便无需重复编写

Oracle-PLSQL基本操作

僤鯓⒐⒋嵵緔 提交于 2019-12-26 09:51:54
Oracle-PLSQL基本操作 1.查询记录并打印 declare --应用型变量:emp.sal是什么类型,那么通过emp.sal%type就可以指明vsal的类型 vsal emp . sal % type ; begin --将值赋给vsal select sal into vsal from emp where empno = 7369 ; --打印 dbms_output . put_line ( vsal ) ; end ; declare --声明记录型变量 vrow emp % rowtype ; begin select * into vrow from emp where empno = 7369 ; dbms_output . put_line ( '姓名' || vrow . ename ) ; end ; 条件判断 declare age number : = & 输入年龄 ; begin if age < 18 then dbms_output . put_line ( '未成年' ) ; elsif age > 18 and age <= 35 then dbms_output . put_line ( '年轻人' ) ; elsif age > 35 and age <= 65 then dbms_output . put_line ( '中年人'

vim创建新文件自动添加自定义信息

别等时光非礼了梦想. 提交于 2019-12-26 09:44:30
vim创建新文件自动添加自定义信息 用vim创建新文件时会相应地给出该文件属性的自定义信息,以Ubuntu 18.04系统为例,当创建.sh脚本文件时: 当创建.cpp源文件时: 以管理员方式用vim打开其配置文件.vimrc,命令如下: sudo vim /etc/vim/vimrc 输入密码后,进入如下界面: 输入“i”进入编辑状态,并把如下信息复制在文件末尾,信息如下: let g:pydiction_location = '~/.vim/after/complete-dict' let g:pydiction_menu_height = 20 let Tlist_Ctags_Cmd='/usr/local/bin/ctags' let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 autocmd FileType python set omnifunc=pythoncomplete#Complete set rtp+=~/.vim/bundle/vundle set fencs=utf-8,ucs-bom,shift-jis

xml操作-Nested exception: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId. 异常处理

♀尐吖头ヾ 提交于 2019-12-25 23:11:11
异常如下: org.dom4j.DocumentException: Error on line 2 of document file:///D:/workspaces/struts2/lesson01/src/newfile.xml : White spaces are required between publicId and systemId. Nested exception: White spaces are required between publicId and systemId. at org.dom4j.io.SAXReader.read(SAXReader.java:482) at org.dom4j.io.SAXReader.read(SAXReader.java:264) at dom.TestDom.testAddElement(TestDom.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke

matplotlib.pyplot scatterplot lines using lists for x-coordinates, y-coordinates, and colors

独自空忆成欢 提交于 2019-12-25 17:08:42
问题 Matplotlib connect scatterplot points with line - Python Checked this out and their solution was very simple, use plt.plot(x_coordinates, y_coordinates, '-o') but I have a list of colors that i'm using so I can't use this method. They are RGB colors. (Also not sure why colors are alternating within the same series) How can I connect these points with lines that are the same color as the markers? import matplotlib.pyplot as plt import random x_coordinates = [(range(1,4))]*2 y_coordinates = [[3

Interpolate line data to grid matlab

房东的猫 提交于 2019-12-25 16:38:53
问题 i have a matrix consist of 5 columns the first and second columns are for x_start & y_start of the line, the third and fourth are for x_end & y_end the fifth is -concentration of contaminant in this line- for example: % x_start y_start x_end y_end concentration frac= [0 0 1 1 0.3 1 1 3 3 0.6 3 3 10 2 1.2 3 3 10 8 0.5]; if i assume that i have a domain of interest 10mx10m and this domain is divided by finite difference cell size 1mx1m (i.e domain is 10 cells by 10 cells) and i want to

Plot several lines with color based on a value in matlab

拥有回忆 提交于 2019-12-25 16:28:19
问题 I have a matrix consisting of 5 columns. The first and second columns are for x_start & y_start of the line, the third and fourth are for x_end & y_end. The fifth is -concentration of contaminant in this line- giving the value for the color of my graph. I want to plot x_start & y_start with x_end & y_end for each line and give this line a color based on the value of concentration which is ranging in color from Cmin to Cmax within a colormap. Any help? 回答1: I hope I've understood your question

Plot several lines with color based on a value in matlab

可紊 提交于 2019-12-25 16:28:01
问题 I have a matrix consisting of 5 columns. The first and second columns are for x_start & y_start of the line, the third and fourth are for x_end & y_end. The fifth is -concentration of contaminant in this line- giving the value for the color of my graph. I want to plot x_start & y_start with x_end & y_end for each line and give this line a color based on the value of concentration which is ranging in color from Cmin to Cmax within a colormap. Any help? 回答1: I hope I've understood your question