凭海临风的IT江湖

  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 站点地图

  • 公益 404

  • 时间轴

  • 搜索

javascript-undefined-description

发表于 2019-06-11 | 更新于 2022-08-18 | 分类于 javascript
本文字数: 821 | 阅读时长 ≈ 1 分钟

Javascript 基础拾遗之undefined

先看一个例子:

1
2
3
var a;
console.log(a);//undefined
console.log(typeof(a)); //undefined

javascript中的数据类型包括undefined,null,boolean,number,string,boolean六种类型(ECMAScript 2015)

undefined 小结

undefined 类型的意思是当前对象未定义,适用于下面几种情况

  1. 变量声明,但未赋值
  2. 对象没有赋值的属性,该属性的值为undefined
  3. 调用函数参数,但是未提供参数,该参数的值为undefined
  4. 函数没有返回值时,默认返回undefined

再看下面的例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//1.
var i;
console.log(i);
//2.
var o = new Object();
console.log(o.p);
//3.
function test(a){
console.log(typeof a); // undefined
return a;
}
test();
//4.
myfunc()
function myfunc(){
//console.log("my function.");
}
console.log(myfunc());

需要区别下面这个情况,不同浏览器提示信息可能会不同(Chrome和IE测试)

1
2
console.log(b);
// Uncaught ReferenceError: b is not defined

如何判断为空

下面三种判断方法:

1
2
3
4
5
6
// 方式1
if(typeof age === 'undefined')
// 方式2
if(age === undefined)
// 方式3
if(varName) //万能判断,包括boolean

参考文档

火狐JavaScript教程

stackoverflow如何检查undefined

Build path entry is missing /src/test/java missing问题解决

发表于 2019-06-03 | 更新于 2022-08-18 | 分类于 javaweb
本文字数: 162 | 阅读时长 ≈ 1 分钟

[问题描述]

通过maven构建webapp,发现缺少java和test目录

[解决方案]

project –right click –build path– config build path – libraries – double click “JRE System Library”–choose “workspace default JRE” OK

如下图所示

how-to-fix-cannot-change-version-of-project-dynamic-web-module-to-3.1-in-Eclipse

发表于 2019-06-03 | 更新于 2022-08-18 | 分类于 javaweb
本文字数: 846 | 阅读时长 ≈ 1 分钟

1.问题描述

试图转换Dynamic Web Module 发生如下错误:

1
2
Cannot change version of project facet Dynamic Web Module to 3.0 
One or more constraints have not been satisfied
阅读全文 »

hexo建站搭建流程

发表于 2019-05-31 | 更新于 2022-08-18 | 分类于 搭建博客
本文字数: 2.8k | 阅读时长 ≈ 3 分钟
  1. 下载并安装 Visual Studio Code, 官方下载

  2. 下载并安装 Nodejs, 官方下载

    1
    2
    node -v
    npm -v

    npm 镜像源修改为 淘宝NPM镜像

    1
    npm install -g cnpm --registry=https://registry.npm.taobao.org
  3. 下载并安装 Git, 官方下载

    1
    2
    3
    #配置名字和邮箱
    git config --global user.name "test"
    git config --global user.email "test@.com"
  1. 安装 Hexo, 官方文档

    1
    2
    cnpm install -g hexo-cli
    hexo -v

    初始化博客目录

    1
    2
    3
    4
    cd D
    hexo init blog
    cd blog
    cnpm install

    启动服务器,本地预览

    1
    hexo server
阅读全文 »

python创建字典的几种方法

发表于 2019-05-28 | 更新于 2022-08-18 | 分类于 python
本文字数: 1.3k | 阅读时长 ≈ 1 分钟

python创建字典的几种方法

1. 创建空字典

1
2
3
>>> dic = {}
>>> type(dic)
<type 'dict'>

另一种形式:

1
2
temp = dict()
temp['name'] = 'xiaoming'

2. 直接赋值创建

1
2
3
>>> dic = {'spam':1, 'egg':2, 'bar':3}
>>> dic
{'bar': 3, 'egg': 2, 'spam': 1}

3. 通过关键字dict和关键字参数创建

1
2
3
>>> dic = dict(spam = 1, egg = 2, bar =3)
>>> dic
{'bar': 3, 'egg': 2, 'spam': 1}
阅读全文 »

python操作sqlite3

发表于 2019-05-28 | 更新于 2022-08-18 | 分类于 python
本文字数: 6.8k | 阅读时长 ≈ 6 分钟

sqlite3 简介

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
SQLite数据库是一款非常小巧的嵌入式开源数据库软件,也就是说
没有独立的维护进程,所有的维护都来自于程序本身。
在python中,使用sqlite3创建数据库的连接,当我们指定的数据库文件不存在的时候
连接对象会自动创建数据库文件;如果数据库文件已经存在,则连接对象不会再创建
数据库文件,而是直接打开该数据库文件。
连接对象可以是硬盘上面的数据库文件,也可以是建立在内存中的,在内存中的数据库
执行完任何操作后,都不需要提交事务的(commit)

创建在硬盘上面: conn = sqlite3.connect('c:\\test\\test.db')
创建在内存上面: conn = sqlite3.connect('"memory:')

下面我们一硬盘上面创建数据库文件为例来具体说明:
conn = sqlite3.connect('c:\\test\\hongten.db')
其中conn对象是数据库链接对象,而对于数据库链接对象来说,具有以下操作:

commit() --事务提交
rollback() --事务回滚
close() --关闭一个数据库链接
cursor() --创建一个游标

cu = conn.cursor()
这样我们就创建了一个游标对象:cu
在sqlite3中,所有sql语句的执行都要在游标对象的参与下完成
对于游标对象cu,具有以下具体操作:

execute() --执行一条sql语句
executemany() --执行多条sql语句
close() --游标关闭
fetchone() --从结果中取出一条记录
fetchmany() --从结果中取出多条记录
fetchall() --从结果中取出所有记录
scroll() --游标滚动
阅读全文 »

selenium元素操作封装

发表于 2019-05-28 | 更新于 2022-08-18 | 分类于 自动化测试
本文字数: 1.7k | 阅读时长 ≈ 2 分钟

selenium 常用的元素定位操作

Selenium提供了8种定位方式。

  • id
  • name
  • class name
  • tag name
  • link text
  • partial link text
  • xpath
  • css selector

这8种定位方式在Python selenium中所对应的方法为:

  • find_element_by_id()

  • find_element_by_name()

  • find_element_by_class_name()

  • find_element_by_tag_name()

  • find_element_by_link_text()

  • find_element_by_partial_link_text()

  • find_element_by_xpath()

  • find_element_by_css_selector()

阅读全文 »

使用selenium访问爱奇艺网站

发表于 2019-05-28 | 更新于 2022-08-18 | 分类于 自动化测试
本文字数: 1.3k | 阅读时长 ≈ 1 分钟

使用selenium访问爱奇艺网站

selenium 是一种常用的自动化测试工具。它支持各种浏览器,包括 Chrome,Safari,Firefox 等主流界面式浏览器,如果你在这些浏览器里面安装一个 Selenium 的插件,还可以通过录制,快速生成脚本。

selenium 支持多种主流的开发语言,比如Ruby,java,python,javascript。

环境搭建

python3.7.3

运行 pip install selenium 就可以直接下载最新的selenium版本

准备

浏览器:chrome 70.0.3538.77

操作系统:win7

selenium版本: 3.14.1

chromedriver: https://npm.taobao.org/mirrors/chromedriver/70.0.3538.97/

使用selenium 打开和关闭浏览器

1
2
3
4
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.iqiyi.com/")
driver.quit()
阅读全文 »

Hello World

发表于 2019-05-28 | 更新于 2022-08-18
本文字数: 357 | 阅读时长 ≈ 1 分钟

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

copy maven dependencies to a folder

发表于 2016-09-30 | 更新于 2022-08-18 | 分类于 java
本文字数: 1.4k | 阅读时长 ≈ 1 分钟

copy maven dependencies to a folder

background

一个简单的需求,当你的同事需要调试代码的时候,他并不想建立maven环境,这时候依赖的jar包 该如何导出呢?

no code say nothing

这时候你需要的是maven-dependency-plugin。

添加依赖配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>

此处的<outputDirectory> 指定了你导出jar包的路径.

执行命令 mvn dependency:copy-dependencies

查看项目多了一个/alternateLocation目录,并且依赖的jar包都下载到这个目录下了。

1…12131415
Jeff Sui

Jeff Sui

148 日志
36 分类
169 标签
RSS
GitHub E-Mail
  • 20201
  • 2to31
  • Boolean1
  • Centos2
  • Exception1
  • GIL1
  • GitGutter1
  • Tkinter1
  • TypeScript2
  • XML2
  • __all__1
  • _thread1
  • app1
  • argparse2
  • array1
  • atexit1
  • bisect1
  • calendar1
  • centos1
  • checkbox1
  • cmath1
  • cmd1
  • code1
  • collections.abc1
  • concurrent1
  • context-manager-types1
  • cookies1
  • copy1
  • coroutines1
  • csv1
  • cygwin1
  • dataclasses1
  • dbm1
  • dict1
  • dictionary1
  • difflib1
  • dis1
  • django4
  • docker3
  • doctest1
  • dom1
  • eclipse1
  • enum1
  • es61
  • esp323
  • esptool1
  • ffmpeg1
  • filecmp1
  • fileinput1
  • fractions1
  • functools1
  • futures1
  • gc1
  • generator1
  • git4
  • gitcafe1
  • github1
  • glob1
  • heapq1
  • hexo2
  • html.parser1
  • http2
  • http.server1
  • ios1
  • iterator1
  • itertools1
  • java3
  • javascript6
  • javaweb2
  • jdk1
  • jira1
  • json1
  • juypter1
  • keyword1
  • linecache1
  • linter1
  • linux2
  • lite-server1
  • m3u81
  • maven4
  • micorpython1
  • micropython2
  • minidom1
  • modulefinder1
  • mongodb1
  • mybatis1
  • mysql1
  • nbextension1
  • nginx1
  • nodejs1
  • oop1
  • operator1
  • os1
  • os.path1
  • others1
  • pathlib1
  • photo1
  • pickle1
  • pprint1
  • pwd1
  • python96
  • python31
  • queue1
  • re1
  • readline1
  • registry2
  • registry-ui2
  • reprlib1
  • rust1
  • sax1
  • sched1
  • select1
  • selectors1
  • selenium3
  • shutil1
  • socket1
  • sort1
  • spring1
  • sqlite32
  • ssm1
  • standar_library1
  • standard_library78
  • statistics1
  • string1
  • sublime1
  • tempfile1
  • this1
  • thread1
  • timeit1
  • turtle2
  • types1
  • uPycraft1
  • unittest1
  • urllib.robotparser1
  • uuid1
  • uv1
  • venv1
  • vscode1
  • weakref1
  • web test2
  • webbrowser1
  • webrepl1
  • windows3
  • xml2
  • 二维码1
  • 办公1
  • 博客3
  • 坑1
  • 字典1
  • 异步1
  • 循环1
  • 感悟1
  • 持续集成1
  • 搭建1
  • 搭建博客1
  • 文章1
  • 杂记3
  • 版本管理2
  • 短网址1
  • 禅道1
  • 笔记1
  • 约束1
  • 网易音乐1
  • 美化1
  • 自动化测试1
  • 软件工程1
  • 逆向工程1
  • 闭包1
  • 项目管理2
© 2015 – 2025 Jeff Sui | 818k | 12:24
由 Hexo 强力驱动 v3.9.0
|
主题 – NexT.Gemini v7.1.1
|
0%