自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(59)
  • 收藏
  • 关注

原创 二倍图缩放问题解决思考

二倍图缩放问题解决思考 问题由来 在做网页端开发时经常会出现缩放问题,比如我在布局一个5050的图片在移动端时,会被放大为100100(按照1:2的像素比),这时候会产生图片模糊的现象。 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-huI9OSba-1623638461064)(F:\移动端网页布局\images\apple50(1)].jpg) 解决方法 准备一张100*100像素的图片 缩小为50*50像素的图片 到移动端时自动放大为100*100的原来的图片 [外

2021-06-14 10:42:01 572

原创 上下文管理器

文件上下文管理器自动关闭文件 """ with open() as 名字 student.txt hello world word ppt excel """ ## 读取student的内容复制到b中 with open("student.txt","r") as f,open("b.txt","w+") as f2: f2.write(f.read()) f2.seek(0,0)##因为读取后指针在最后所以需要将指针移动到开头 print(f2.read()) ...

2021-04-23 17:49:52 152

原创 100行每一行随机整数生成

""" 创建一个100行的文件,并且每一行随机生成一个100以内的整数 """ import random f = open("a.txt","w+") for i in range(100): f.write(str(random.randint(1,100))+"\n")##类型必须都相同的才能拼接 f.seek(0,0)##将指针运动到开头,这时候不需要是b二进制打开 print(f.read()) f.close() ...

2021-04-23 17:41:29 611

原创 文件的读取和指针

文件读取 student.txt hello world word ppt excel 读取一行 f = open("student.txt","r+") print(f.readline())##读取一行 f.close() hello world 读取每一行并且存入列表中 f = open("student.txt","r+") print(f.readlines())##读取每一行并且存入列表中 f.close() ['hello world\n', 'word ppt excel\n']

2021-04-23 17:31:36 465

原创 文件的读取和写入,文件的复制

文件的读取和写入 写入 f = open("nothing.txt","r")##默认为r读 ##因为在目录中并没有这个文件所以会报错 f.close()##记得要关闭 FileNotFoundError: [Errno 2] No such file or directory: 'nothing.txt' 写入 f = open("nothing.txt","w")##w为写入 ##没有文件则创建一个文件,然后清空后写入 f.write("你好世界!")##写入的内容 f.close()##记得要关闭

2021-04-23 17:08:37 301

原创 Python中的sys中的stdout

Stdout的用法 import sys temp = sys.stdout##先在ys.stdout = open("student.txt","w")之前定义才有效 sys.stdout.write(str(123))##实现print的功能,print实际上就是外设输入的数据写到了stdout流 sys.stdout = open("student.txt","w")##在创建一个文件并且写入 print("hello world")##在文件中写入的内容 print("word ppt excel

2021-03-31 20:14:02 563

原创 pythonstring包的使用

string包的使用 """输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。""" import string content = input("请您输入内容:") char = 0 space = 0 digit = 0 other = 0 for i in range(len(content)): if content[i].isalpha():##判断是否为字母 char+=1 elif content[i].isspace():##判断是否为空格

2021-03-30 18:08:00 583

原创 Python中的datetime模块

datetime datetime用于计算与时间相关的问题 """输出指定格式的日期。""" import datetime # 输出今日日期,格式为 dd/mm/yyyy。更多选项可以查看 strftime() 方法 a = datetime.date.today()##获取当天的日期 print(a) print(a.year)##分别获取年月日 print(a.month) print(a.day) print(a.__format__("%Y-%m-%d"))#转为字符串 print(a.

2021-03-29 11:53:20 101

原创 Python中的exit

sys.exit(0)和os._exit import os, sys try: sys.exit(0)##退出当前程序 except: print('one') finally: print('two') try: os._exit(0)##直接将程序终止 except: print('three') print('four')#不打印直接退出了 """最终打印出 one two """ exit(0) exit(1) exit(0)##无错误退

2021-03-24 15:23:40 250

原创 isinstance用法

isinstance用法 isinstance(a,b)判读a和b的数据类型是否相同 a = 23 print(isinstance(a,str)) ## False b = "wangt" print(isinstance(b,str)) ##True c = 20.11 print(isinstance(c,float)) ##True d = 20.12 print(isinstance(d,(int,float,str,list)))##可以在里面定义多种类型进行比较 ##True

2021-03-24 15:01:57 272

原创 直接插入排序

直接插入排序 从索引1开始,将后面元素以此插入列表中,进行有序排序 package Sort; import java.lang.reflect.Array; import java.util.Arrays; public class Demo03 { public static int[] num(int[] num){ for (int i = 1; i < num.length; i++) {//外侧循环逐渐扩大 for (int j = i;

2021-03-21 14:28:38 117

原创 选择排序

选择排序 将第一个依次与其他几个数进行比较排序,以此类推然后是第二个数,第三个数------- package Sort; import java.lang.reflect.Array; import java.util.Arrays; public class Choice { public static int[] choice(int[] num ){ int parameter=0; for (int i = 0; i < num.length; i

2021-03-21 09:27:34 98

原创 Python的格式化输出

Python的格式化输出 最基本的{0}{1}输出 print("{0} {1} {0}".format("hello","world")) ##{0}代表第一个hello ##{1}代表第二个world 输出为hello world hello 通过{名字}输出 print("{name} {age} {sex}".format(name="张三",age=20,sex="男")) ## name age sex 根据=后面的值进行格式化输出 通过字典格式化输出 dict = {"name":"

2021-03-20 22:04:04 501

原创 java的异常处理

java的异常处理 try catch finally package Test; public class Demo01 { public static void main(String[] args) { int a = 1; int b = 0; //ctrl + alt + t try { System.out.println(a/b); } catch (Exception e

2021-03-19 17:24:00 152

原创 java内部类

java内部类 内部类: 在一个类中在定义一个类 成员内部类 调用 package Demo07; public class Application { public static void main(String[] args) { Outer outer = new Outer(); //使用外部类来new出内部类 Outer.Inner inner = outer.new Inner(); inner.say();

2021-03-18 18:58:04 129

原创 java接口

接口 package Demo06; /*接口的本质是一种约束和规范,所以不具备实现具体方法的可能,需要通过一个 实现类来实现 */ //接口使用interface修饰 public interface UserService { //接口中定义的方法都是抽象方法public abstract不能实现具体方法 //需要通过实现类来实现 public abstract void add(); //public abstract 直接可以省略 void delete()

2021-03-17 13:54:12 131

原创 abstract抽象类/方法

abstract抽象类/方法 抽象类/方法 package Demo05; //使用abstract修饰的类为抽象类 public abstract class Action { //使用abstract修饰的方法为,抽象方法,抽象方法只有方法名,没有方法的实现 public abstract void nothing(); } /* 抽象类中可以没有抽象方法 抽象方法必须为抽象类 */ 抽象方法的实现 package Demo05; //有抽象方法的抽象类其继承的子类必须要实现它的方法

2021-03-17 13:20:25 287

原创 java中的static详解

static static修饰的属性调用的区别 package Demo04; public class Student extends Person { public static int age;//静态属性 public String name;//非静态属性 public static void main(String[] args) { Student student=new Student(); //静态和非静态属性都可以通过new一个对象

2021-03-16 19:43:12 226

原创 java中instanceof 和 子类父类之间的转换

instanceof 判断两者是否有继承关系 调用类 package Demo04; public class Application { public static void main(String[] args) { //instanceof 一条线的线性指向关系,在这条线的为true //主要与左边的类型有关,右边为指向关系 //Object>Person>Student || Teacher Student stu

2021-03-16 18:53:22 2284

原创 Java的多态

Java的多态 调用类 package Demo04; public class Application { public static void main(String[] args) { //一个对象的实际类型是确定,但是可以指向的引用类型不确定 Student s1 = new Student(); Person s2 = new Student(); Object s3 = new Student(); //父

2021-03-15 16:54:06 131

原创 Java的继承

Java的继承 Object类 所有的类默认继承Object类 Ctrl+H 查看继承关系 类的继承 父类 package Demo03; public class Person { /*修饰符 优先级 public protected private */ public void say(){ System.out.println("说句话"); } private String name; public Str

2021-03-15 13:12:47 175

原创 Java的封装

Java的封装 package Demo02; public class Person { //属性私有,private 私有的 //封装一般对属性进行封装 private String name; private int ID; private int age; //get 获取数据 public String getName(){ return this.name; } //set 给数据赋值 publ

2021-03-13 16:58:29 97

原创 Java的对象和类,构造器详解

Java的对象和类 package OPP; //学生的类,一个类中只存在属性和方法 public class Student { //属性 String name;//没有赋值默认值为null int age;//默认值为0 //方法 public void student(){ System.out.println(this.name+"在学习"); } } package OPP; //一个项目应该只存在一个main方法,在主程序

2021-03-12 18:35:07 159

原创 Java方法调用的回顾,值传递,引用传递的解读

Java方法调用的回顾 package oop; public class Demo02 { public static void main(String[] args) { //静态方法 用static修饰 Student.say();//直接调用 //非静态方法 //类名 对象名 对象值 Student student = new Student(); student.criticism(

2021-03-11 20:04:59 70

原创 Java定义方法回顾

Java定义方法 package oop; public class Demo01 { public static void main(String[] args) { } /* 修饰符 返回值类型 方法名 (方法参数){ 方法体 return 返回值与返回值类型相同 } */ public String say(){ return "hello,world"; } /*

2021-03-11 19:22:10 90

原创 稀疏数组

稀疏数组 package reck; public class Demo07 { public static void main(String[] args) { int[][] arrays=new int[11][11]; arrays[1][2]=1; arrays[2][3]=2; for (int i = 0; i < arrays.length; i++) { for (int j = 0;

2021-03-10 21:29:04 132

原创 java的冒泡排序

java的冒泡排序 package reck; import java.util.Arrays; public class Demo06 { public static void main(String[] args) { int[] a ={1,3,4,55,32,56,32,123,466,2}; int[] sort = sort(a); System.out.println(Arrays.toString(sort)); }

2021-03-10 19:28:20 79

原创 java的Arrays基本用法

Arrays用法 Arrays.toString package reck; import java.util.Arrays; public class Demo05 { public static void main(String[] args) { int[] a ={1,33,4,5,66,23,56,78}; System.out.println(a);//[I@14ae5a5 //直接打印输出是输出了一个对象 System

2021-03-10 14:54:37 230

原创 java的多维数组

二维数组 可以理解为一个数组里面嵌套了另一个数组 如何程序的概念都应该在程序中体现和分析 package reck; public class Demo03 { public static void main(String[] args) { /* 动态的表示 */ int[][] a=new int[2][5]; //定义了外面数组长度为2,里面每一个数组长度为5 a[0][0]=

2021-03-09 20:43:26 206

原创 Java数组的进阶

Java数组的进阶 求数组中的最大值 package reck; public class Demo02 { public static void main(String[] args) { //求数组中的最大值 int[] num={1,2,3,4,5}; int max = 0;//先定义一个值 for (int i = 0; i < num.length; i++) {//遍历数组中的元素 if(n

2021-03-09 14:43:21 224

原创 java的数组的静态初始化和动态初始化

package reck; public class Demo01 { public static void main(String[] args) { //创建之后直接赋值 int[] a = {1,2,3,4,5}; System.out.println(a[2]); int[] b=new int[4];//声明并创建 b[0]=10;//手动赋值 System.out.println(b[0.

2021-03-08 20:04:06 245

原创 Java的数组

Java的数组 public class Demo18 { public static void main(String[] args) { int[] nums;//1.声明一个数组 nums = new int[5];//2.创建一个为5的数组 //通常可以合为一步 int[] nums = new int[5] //给数组赋值 nums[0]=1; nums[1]=2; nums[2

2021-03-08 12:40:43 95

原创 Java的递归

Java的递归 public class Demo17 { public static void main(String[] args) { //阶乘的计算 System.out.println(f(10)); } public static int f(int a){ if (a==1){ return 1;//边界条件 }else {//递归自己调用自己 return

2021-03-07 16:05:23 140

原创 # Java的可变参数

Java的可变参数 public class Demo16 { public static void main(String[] args) { Demo16 demo16 = new Demo16();//调用与实例变量调用一样 //因为test没有static所以不能直接调用 demo16.test(1,2,3);//传递的数 } //可变参数:只能指定一个可变参数

2021-03-07 10:10:41 108

原创 Java方法的重载

Java方法的重载 方法重载:在类中方法名称相同,但是形式参数不同 public class Demo15 { public static void main(String[] args) { int sum= max(30,30); System.out.println(sum); double sumDouble = max(33.2,55.4); } public static int max(int a,int b){

2021-03-07 08:54:20 175

原创 Java的方法

Java的方法 public class Demo14 { public static void main(String[] args) { int sum=add(1,2);//方法的调用 //实际参数 System.out.println(sum); } //形式参数 public static int add(int a,int b){ //要加static变为

2021-03-06 13:37:19 98

原创 java打印三角形

利用循环打印出三角形 public class Demo13 { public static void main(String[] args) { for (int i = 1; i <=5; i++) { for (int d = 5;d>=i;d--){ System.out.print(" "); //打印空格 } for (int

2021-03-05 18:08:45 113

原创 java中的break和continue以及goto标签

break public class Demo12 { public static void main(String[] args) { int i = 0; while (i<100){ i++; if (i==30){ break;//直接终止循环 } System.out.println(i);

2021-03-05 17:51:36 102

原创 # Java的循环结构

Java的循环结构 while循环结构 先判断后循环 public class Demo09 { public static void main(String[] args) { //从1输入到100 int i = 0; //while (布尔表达式) {循环内容} while (i<100){ i++; System.out.println(i); } }

2021-03-04 23:52:24 153 1

原创 Java的判断结构

Java的判断结构 if 单选择结构 import java.util.Scanner; public class Demo04 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入hello:"); String str = scanner.nextLine(); if

2021-03-03 18:23:43 317 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除