登录+注册界面的实现(代码)

article/2025/10/3 1:00:32

先看效果图!

这里写图片描述 这里写图片描述

话不多说,直接上代码!

//布局文件:activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:custom="http://schemas.android.com/apk/res-auto"android:layout_width="fill_parent"android:layout_height="fill_parent"android:fitsSystemWindows="true"><RelativeLayout
        android:id="@+id/login_layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:gravity="center"><FrameLayout
            android:id="@+id/username_layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="55dp"android:gravity="center"><EditText
                android:id="@+id/username"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"android:inputType="number"android:maxLength="20"android:paddingLeft="55dp"android:paddingRight="60dp"android:hint="6位数字账号"/><ImageView
                android:layout_width="28dp"android:layout_height="28dp"android:layout_gravity="left|center_vertical"android:layout_marginLeft="8dp"android:layout_marginStart="8dp"android:background="@drawable/login_username"android:visibility="visible" /><Button
                android:id="@+id/bt_username_clear"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="10dp"android:background="@drawable/login_delete"android:visibility="invisible" /></FrameLayout><FrameLayout
            android:id="@+id/usercode_layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/username_layout"android:layout_marginTop="6dp"android:gravity="center"><EditText
                android:id="@+id/password"android:layout_width="fill_parent"android:layout_height="wrap_content"android:inputType="textPassword"android:maxLength="20"android:paddingLeft="55dp"android:paddingRight="60dp"android:hint="6位密码"/><ImageView
                android:layout_width="28dp"android:layout_height="28dp"android:layout_gravity="left|center_vertical"android:layout_marginLeft="7dp"android:layout_marginStart="7dp"android:background="@drawable/login_password" /><Button
                android:id="@+id/bt_pwd_clear"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="10dp"android:background="@drawable/login_delete"android:visibility="invisible" /><!--            <Buttonandroid:id="@+id/bt_pwd_eye"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="33dp"android:background="@drawable/login_illegal" />--></FrameLayout><Button
            android:id="@+id/login"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/usercode_layout"android:layout_marginTop="30dp"android:background="#ff336699"android:gravity="center"android:text="登 录"android:textColor="@android:color/white"android:textSize="24dp" />android:layout_height="@dimen/default_button_height"</RelativeLayout><Button
        android:id="@+id/register"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentEnd="true"android:layout_alignParentRight="true"android:background="#00000000"android:text="注册"android:textSize="16sp"android:textColor="#63B8FF" />android:visibility="visible"<Button
        android:id="@+id/login_error"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"android:background="#00000000"android:text="忘记密码"android:textSize="16sp"android:textColor="#63B8FF"/><CheckBox
        android:id="@+id/checkBox1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/login_layout"android:layout_alignStart="@+id/login_layout"android:layout_below="@+id/login_layout"android:layout_marginTop="28dp"android:text="记住密码" /><CheckBox
        android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="自动登录"android:id="@+id/checkBox2"android:layout_below="@+id/checkBox1"android:layout_alignLeft="@+id/checkBox1"android:layout_alignStart="@+id/checkBox1" /><!--<RelativeLayoutandroid:id="@+id/remember_layout000"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_marginBottom="1dp"android:layout_marginLeft="20dp"android:layout_marginRight="20dp" ><Buttonandroid:id="@+id/registfer"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="#00000000"android:gravity="center"android:singleLine="true"android:text="AnyLife,Make the world a better place."android:textSize="16sp"android:visibility="visible" /></RelativeLayout>-->
</RelativeLayout>
//布局文件:activity_regist.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"><RelativeLayout
        android:id="@+id/regist_layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginRight="20dp"android:gravity="center"><FrameLayout
            android:id="@+id/username_layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="55dp"android:gravity="center"><EditText
                android:id="@+id/username_regist"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_marginTop="5dp"android:hint="6位数字账号"android:inputType="number"android:maxLength="20"android:paddingLeft="90dp"android:paddingRight="60dp" /><Button
                android:id="@+id/bt_username_clear_regist"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="10dp"android:background="@drawable/login_delete"android:visibility="invisible" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="注册账号:"android:textSize="16dp"android:textColor="#333333"android:layout_marginLeft="8dp"android:layout_gravity="left|center_vertical" /></FrameLayout><FrameLayout
            android:id="@+id/usercode_layout_1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/username_layout"android:layout_marginTop="6dp"android:gravity="center"><EditText
                android:id="@+id/password_regist_1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:inputType="textPassword"android:maxLength="20"android:paddingLeft="90dp"android:paddingRight="60dp"android:hint="6位密码"/><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="输入密码:"android:textSize="@dimen/activity_vertical_margin"android:layout_marginLeft="8dp"android:layout_gravity="left|center_vertical"android:textColor="#333333"/><Button
                android:id="@+id/bt_pwd_clear_regist_1"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="10dp"android:background="@drawable/login_delete"android:visibility="invisible" /></FrameLayout><FrameLayout
            android:id="@+id/usercode_layout_2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/usercode_layout_1"android:layout_marginTop="6dp"android:gravity="center"><EditText
                android:id="@+id/password_regist_2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:inputType="textPassword"android:maxLength="20"android:paddingLeft="90dp"android:paddingRight="60dp" /><TextView
                android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="重复密码:"android:textSize="@dimen/activity_vertical_margin"android:layout_marginLeft="8dp"android:layout_gravity="left|center_vertical"android:textColor="#333333"/><Button
                android:id="@+id/bt_pwd_clear_regist_2"android:layout_width="23dp"android:layout_height="23dp"android:layout_gravity="right|center_vertical"android:layout_marginRight="10dp"android:background="@drawable/login_delete"android:visibility="invisible" /></FrameLayout><Button
            android:id="@+id/regist"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_below="@id/usercode_layout_2"android:layout_marginTop="30dp"android:background="#ff336699"android:gravity="center"android:text="立即注册"android:textColor="@android:color/white"android:textSize="24dp" /></RelativeLayout></RelativeLayout>
//LoginActivity.java
public class LoginActivity extends Activity implements View.OnClickListener,View.OnLongClickListener {// 声明控件对象private EditText et_name, et_pass;private Button mLoginButton,mLoginError,mRegister,ONLYTEST;int selectIndex=1;boolean isReLogin=false;private RelativeLayout countryselect;private TextView coutry_phone_sn, coutryName;//private Button bt_username_clear;private Button bt_pwd_clear;// private Button bt_pwd_eye;//记录账号、密码private SharedPreferences sp_userinfo;private CheckBox cb_remenber;private CheckBox cb_autologin;private String userNameValue,passwordValue;private TextWatcher username_watcher;private TextWatcher password_watcher;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
//  requestWindowFeature(Window.FEATURE_NO_TITLE);
//  //不显示系统的标题栏
//  getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN,
//    WindowManager.LayoutParams.FLAG_FULLSCREEN );setContentView(R.layout.activity_login);et_name = (EditText) findViewById(R.id.username);et_pass = (EditText) findViewById(R.id.password);bt_username_clear = (Button)findViewById(R.id.bt_username_clear);bt_pwd_clear = (Button)findViewById(R.id.bt_pwd_clear);//bt_pwd_eye = (Button)findViewById(R.id.bt_pwd_eye);bt_username_clear.setOnClickListener(this);bt_pwd_clear.setOnClickListener(this);//bt_pwd_eye.setOnClickListener(this);initWatcher();et_name.addTextChangedListener(username_watcher);et_pass.addTextChangedListener(password_watcher);mLoginButton = (Button) findViewById(R.id.login);mLoginError  = (Button) findViewById(R.id.login_error);mRegister    = (Button) findViewById(R.id.register);//ONLYTEST     = (Button) findViewById(R.id.registfer);//ONLYTEST.setOnClickListener(this);//ONLYTEST.setOnLongClickListener((OnLongClickListener) this);mLoginButton.setOnClickListener(this);mLoginError.setOnClickListener(this);mRegister.setOnClickListener(this);sp_userinfo = this.getSharedPreferences("userInfo", Context.MODE_PRIVATE);if(sp_userinfo.getBoolean("ISCHECK", false)){//设置默认是记录密码状态//rem_pw.setChecked(true);et_name.setText(sp_userinfo.getString("USER_NAME", ""));et_pass.setText(sp_userinfo.getString("PASSWORD", ""));//判断自动登陆多选框状态if(//sp_userinfo.getBoolean("AUTO_ISCHECK", false)//测试,设为falsefalse){//设置默认是自动登录状态//auto_login.setChecked(true);//跳转界面Intent intent = new Intent(LoginActivity.this,MainActivity.class);LoginActivity.this.startActivity(intent);}}cb_remenber = (CheckBox)findViewById(R.id.checkBox1);cb_autologin =(CheckBox)findViewById(R.id.checkBox2);CompoundButton.OnCheckedChangeListener listener1 = new CompoundButton.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(CompoundButton compoundButton, boolean b) {if (b){//选中,保存密码sp_userinfo.edit().putBoolean("ISCHECK", true).commit();Toast.makeText(LoginActivity.this, compoundButton.getText()+"被选择",Toast.LENGTH_SHORT ).show();}else{//取消选中,删除保存的密码sp_userinfo.edit().putBoolean("ISCHECK", false).commit();Toast.makeText(LoginActivity.this, compoundButton.getText()+"取消选择",Toast.LENGTH_SHORT ).show();}}};cb_remenber.setOnCheckedChangeListener(listener1);CompoundButton.OnCheckedChangeListener listener2 = new CompoundButton.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(CompoundButton compoundButton, boolean b) {if (b){//选中,保存密码sp_userinfo.edit().putBoolean("AUTO_ISCHECK", true).commit();Toast.makeText(LoginActivity.this, compoundButton.getText()+"被选择",Toast.LENGTH_SHORT ).show();}else{//取消选中,删除保存的密码sp_userinfo.edit().putBoolean("AUTO_ISCHECK", false).commit();Toast.makeText(LoginActivity.this, compoundButton.getText()+"取消选择",Toast.LENGTH_SHORT ).show();}}};cb_autologin.setOnCheckedChangeListener(listener2);}/*** 手机号,密码输入控件公用这一个watcher*/private void initWatcher() {username_watcher = new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {}public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void afterTextChanged(Editable s) {et_pass.setText("");if(s.toString().length()>0){bt_username_clear.setVisibility(View.VISIBLE);}else{bt_username_clear.setVisibility(View.INVISIBLE);}}};password_watcher = new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {}public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void afterTextChanged(Editable s) {if(s.toString().length()>0){bt_pwd_clear.setVisibility(View.VISIBLE);}else{bt_pwd_clear.setVisibility(View.INVISIBLE);}}};}@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubswitch (arg0.getId()) {case R.id.login:  //登陆userNameValue = et_name.getText().toString();passwordValue = et_pass.getText().toString();//判断信息是否符合if (userNameValue.toString().length()==6 ) {if (passwordValue.toString().length()==6){if (cb_remenber.isChecked()) {//记住用户名、密码、SharedPreferences.Editor editor = sp_userinfo.edit();editor.putString("USER_NAME", userNameValue);editor.putString("PASSWORD", passwordValue);editor.commit();}Intent intent_login = new Intent().setClass(LoginActivity.this, MainActivity.class);//Intent intent_login = new Intent();//intent_login.putExtra("fragment",0);startActivity(intent_login);}else{Toast.makeText(LoginActivity.this, "密码格式错误!", Toast.LENGTH_LONG).show();}}else{Toast.makeText(LoginActivity.this, "账号格式错误!", Toast.LENGTH_LONG).show();}break;case R.id.login_error: //无法登陆(忘记密码了吧)AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("忘记密码").setIcon(R.drawable.login_illegal1).setMessage("请拨打:  110 \n").setPositiveButton("确定",null);builder.create().show();break;case R.id.register:    //注册新的用户Intent intent_regist = new Intent(LoginActivity.this, RegistActivity.class);startActivityForResult(intent_regist,0);//请求码为0break;case R.id.bt_username_clear:et_name.setText("");et_pass.setText("");break;case R.id.bt_pwd_clear:et_pass.setText("");break;}}//重写,回调方式来获取RegistActivity返回的数据@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {if (requestCode == 0 && resultCode == 0){Bundle d = data.getExtras();String info = d.getString("info");et_name.setText(info);}}/*** 登陆*/private void login() {}@Overridepublic boolean onLongClick(View v) {// TODO Auto-generated method stubswitch (v.getId()) {//case R.id.registfer://  if(SERVER_FLAG>9){// }//   SERVER_FLAG++;//  break;}return true;}/*** 监听Back键按下事件,方法2:* 注意:* 返回值表示:是否能完全处理该事件* 在此处返回false,所以会继续传播该事件.* 在具体项目中此处的返回值视情况而定.*/@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if ((keyCode == KeyEvent.KEYCODE_BACK)) {if(isReLogin){Intent mHomeIntent = new Intent(Intent.ACTION_MAIN);mHomeIntent.addCategory(Intent.CATEGORY_HOME);mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);LoginActivity.this.startActivity(mHomeIntent);}else{LoginActivity.this.finish();}return false;}else {return super.onKeyDown(keyCode, event);}}}
//RigistActivity.java
package com.example.businesstriphelper.login;import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import com.example.businesstriphelper.R;/*** Created by Administrator on 2016/7/5.*/
public class RegistActivity extends AppCompatActivity implements View.OnClickListener{private EditText et_name, et_pass1,et_pass2;private Button mRegistButton;private Button bt_username_clear;private Button bt_pwd_clear1,bt_pwd_clear2;private TextWatcher username_watcher;private TextWatcher password_watcher1,password_watcher2;//是否显示注册信息核对框private boolean isInfoChecked = false;private String userNameValue,passwordValue1,passwordValue2;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_LEFT_ICON);setContentView(R.layout.activity_regiset);getSupportActionBar().setDisplayHomeAsUpEnabled(true);getSupportActionBar().setTitle("注册");et_name = (EditText) findViewById(R.id.username_regist);et_pass1 = (EditText) findViewById(R.id.password_regist_1);et_pass2 = (EditText) findViewById(R.id.password_regist_2);bt_username_clear = (Button) findViewById(R.id.bt_username_clear_regist);bt_pwd_clear1 = (Button) findViewById(R.id.bt_pwd_clear_regist_1);bt_pwd_clear2 = (Button) findViewById(R.id.bt_pwd_clear_regist_2);bt_username_clear.setOnClickListener(this);bt_pwd_clear1.setOnClickListener(this);bt_pwd_clear2.setOnClickListener(this);initWatcher();et_name.addTextChangedListener(username_watcher);et_pass1.addTextChangedListener(password_watcher1);et_pass2.addTextChangedListener(password_watcher2);mRegistButton = (Button) findViewById(R.id.regist);mRegistButton.setOnClickListener(this);}private void initWatcher() {username_watcher = new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {}public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void afterTextChanged(Editable s) {isInfoChecked = false;if(s.toString().length()>0){bt_username_clear.setVisibility(View.VISIBLE);}else{bt_username_clear.setVisibility(View.INVISIBLE);}}};password_watcher1 = new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {}public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void afterTextChanged(Editable s) {isInfoChecked = false;et_pass2.setText("");if(s.toString().length()>0){bt_pwd_clear1.setVisibility(View.VISIBLE);}else{bt_pwd_clear1.setVisibility(View.INVISIBLE);}}};password_watcher2 = new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {}public void beforeTextChanged(CharSequence s, int start, int count,int after) {}public void afterTextChanged(Editable s) {isInfoChecked = false;if(s.toString().length()>0){bt_pwd_clear2.setVisibility(View.VISIBLE);}else{bt_pwd_clear2.setVisibility(View.INVISIBLE);}}};}@Overridepublic void onClick(View arg0) {switch (arg0.getId()) {case R.id.regist:userNameValue = et_name.getText().toString();passwordValue1 = et_pass1.getText().toString();passwordValue2 = et_pass2.getText().toString();//判断信息是否符合,//千万不要这样写,而是写一个判断方法,if (userNameValue.length()==6 ) {if (passwordValue1.length()==6){if (passwordValue1.equals(passwordValue2)){if (isInfoChecked == false) {isInfoChecked = true;AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle("注册信息").setIcon(R.drawable.login_illegal1).setMessage("账号: " + et_name.getText().toString() + "\n密码: "+ et_pass2.getText().toString()+ "\n请再次点击“立即注册”").setPositiveButton("确定", null);builder.create().show();}else {//注册,携带注册信息返回Intent intent = getIntent();intent.putExtra("info",userNameValue);RegistActivity.this.setResult(0,intent);RegistActivity.this.finish();//Intent intent_login = new Intent().setClass(RegistActivity.this, MainActivity.class);//startActivity(intent_login);}}else{Toast.makeText(RegistActivity.this, "两次密码不一致!"+"\n"+passwordValue1+"\n"+passwordValue2, Toast.LENGTH_LONG).show();}}else{Toast.makeText(RegistActivity.this, "密码格式错误!", Toast.LENGTH_LONG).show();}} else{Toast.makeText(RegistActivity.this, "账号格式错误!", Toast.LENGTH_LONG).show();}break;case R.id.bt_username_clear_regist:et_name.setText("");break;case R.id.bt_pwd_clear_regist_1:et_pass1.setText("");et_pass2.setText("");break;case R.id.bt_pwd_clear_regist_2:et_pass2.setText("");break;}}//标题栏返回按键@Overridepublic boolean onOptionsItemSelected(MenuItem item) {if (item.getItemId() == android.R.id.home) {//不反回,判断语句的问题//android.R 和R的区别://android.R是要获取系统资源时使用的;//R当前应用程序中的资源。Intent intent = getIntent();intent.putExtra("info",et_name.getText().toString());RegistActivity.this.setResult(0,intent);RegistActivity.this.finish();return true;}return super.onOptionsItemSelected(item);}//重写,防止按返回键崩溃@Overridepublic void onBackPressed() {// super.onBackPressed();   不要调用父类的方法Intent intent = getIntent();intent.putExtra("info",et_name.getText().toString());RegistActivity.this.setResult(0,intent);RegistActivity.this.finish();}
}

以上,希望对你有用!


http://chatgpt.dhexx.cn/article/wE4WtNTt.shtml

相关文章

简单WEB登录页面代码实现

longin.html&#xff1a;登录页面&#xff0c;此处action引用**/**类型的地址&#xff0c;JSP可以用${ pageContext.request.contextPath }/LS <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd&qu…

编写简单的登陆页面

1.简单登录界面&#xff08;自己设置css样式&#xff09; 代码如下 <form id"loginForm" action"#" method"post" novalidate"novalidate"><div class"login_box"><div class"login_box_left"&g…

实现网页登录代码

python 一、前言 本文通过selenium工具实现工作所用网站的自动登录&#xff0c;下图为网站登录界面。 1、运行环境 操作系统&#xff1a;Windows10 python版本&#xff1a;python3.7 2、需要的python第三方库 1、selenium 安装&#xff1a; pip install selenium selen…

【html】【一个简单的用户登录页面代码】

结果 代码 <!DOCTYPE html> <html><head><title>用户登录.html</title><meta http-equiv"keywords" content"keyword1,keyword2,keyword3"><meta http-equiv"description" content"this is my pag…

html 【一个简单的用户登录页面代码】

效果图 <!DOCTYPE html> <html><head><title>用户登录.html</title><meta http-equiv"keywords" content"keyword1,keyword2,keyword3"><meta http-equiv"description" content"this is my page&…

简单登录页面html代码

【实例简介】 js/html基础示例&#xff1a;简单登录页面 【实例截图】 【核心代码】 文档&#xff1a;590m.com/f/25127180-496787472-732294&#xff08;访问密码&#xff1a;551685&#xff09; 以下内容无关&#xff1a; -------------------------------------------分…

登录界面源代码

拿走请三联&#xff0c;并注明出处&#xff01; 没有上传原背景图&#xff0c;使用的话需自己更改图片名称 可连接注册界面&#xff0c;和用户照片墙&#xff0c;此文只有登录界面代码&#xff0c;代码存在些许问题&#xff0c;望观看的大佬们多多指教&#xff01; <!DOC…

python实现网站的自动登录(selenium实现,带验证码识别)

python实现网站自动登录&#xff08;selenium实现&#xff0c;带验证码识别&#xff09; 一、前言 这是鄙人写的第一篇博客&#xff0c;旨在总结一下近期所学&#xff0c;本文通过selenium工具实现工作所用网站的自动登录&#xff0c;下图为网站登录界面。 1、运行环境 操作…

登录页面的代码

登录页面的代码 在把页面和数据库做好之后&#xff0c;我的登录页面只需要 用户名和密码 &#xff0c;所以代码比较简单。 先找到登录按钮&#xff0c;给一个点击事件&#xff0c;然后再获取他们的表单值&#xff0c;然后对用户名和密码进行判断&#xff0c;判断是否填写了资料…

核函数(多项式,高斯核)以及svm解决回归问题

文章目录 一、SVM最优化问题转换1、多项式核函数 二、高斯核函数1.引入库1、多项式特征2、高斯核函数升维举例3、高斯核函数超参数gamma 三、svm解决回归问题总结 一、SVM最优化问题转换 变换为数学上一个更好解的 在这个式子中有重要的一项Xi&#xff0c;Xj 两个样本的点乘…

高斯核-高斯模糊

大白话高斯模糊 以二维高斯为例&#xff0c;公式&#xff1a; 高斯模糊的原理,可以理解成每一个像素都取周边像素的加权平均值 以高斯分布取g矩阵的值得到的模糊方法即为高斯模糊 权重矩阵 假定中心点的坐标是&#xff08;0,0&#xff09;&#xff0c;那么距离它最近的8个点的…

数值实验-高斯核函数 python/matlab 实现

支持向量机 支持向量&#xff1a;支持平面把两类类别划分开的超平面的向量点机&#xff1a;一种算法SVM 是一种二分类模型线性可分支持向量机&#xff1a;通过硬间隔最大化&#xff0c;学习一个线性分类器线性支持向量机&#xff1a;通过软间隔最大化&#xff0c;学习一个线性…

CS131专题-2:高斯核、噪声、滤波

目录 1 高斯核 1.1 一维定义 1.2 二维定义 1.2.1 应用高斯核的过程 1.2.2 不同σ值的高斯核情况 1.2.3 不同核宽度情况 1.2.4 高斯核&#xff08;滤波&#xff09;特性 1.2.5 使用高斯核做平滑滤波相对箱式滤波的优点 2 噪声 和 滤波 2.1 椒盐噪声、脉冲噪声 2.1.1 …

python高斯核函数_机器学习:SVM(核函数、高斯核函数RBF)

一、核函数(Kernel Function) 1)格式 K(x, y):表示样本 x 和 y,添加多项式特征得到新的样本 x、y,K(x, y) 就是返回新的样本经过计算得到的值; 在 SVM 类型的算法 SVC() 中,K(x, y) 返回点乘:x . y 得到的值; 2)多项式核函数 业务问题:怎么分类非线性可分的样本…

高斯整数matlab,Matlab---自适应高斯核

MCNN提出了适用于高密度人群的自适应高斯核: 笔者所理解的自适应高斯核函数: %function:通过高斯核产生相应的密度矩阵 %parameter: im:输入图像,灰度图; points:标注的点[X Y],n*2的矩阵 function im_density = get_density_map_autogaussian(im,points) im_density =…

高斯核原理详解+生成高斯核的Python代码

要搞清楚高斯核的原理的话&#xff0c;把下面这篇博文认认真真看一遍就可以了&#xff0c;链接如下&#xff1a; https://blog.csdn.net/u013066730/article/details/123112159 下面是我认为值得注意和需要补充说明的几点&#xff1a; 1 为什么高斯滤波能够让图像实现模糊化&a…

C语言哈希表UT_hash的使用方法详解

由于C语言本身不存在哈希,因此&#xff0c;我们可以调用开源的第三方头文件&#xff0c;这只是一个头文件&#xff1a;uthash.h&#xff0c;使用时只需要在文件首部编写#include<uthash.h>即可。 uthash的使用 #include "uthash.h" struct my_struct {int id…

utxo 是什么

UTXO 代表 Unspent Transaction Output。 在比特币社区里&#xff0c;Transaction 被简称为 TX&#xff0c;所以上面这个短语缩写为 UTXO。一般会认为 UTXO 是比特币区块链设计当中的一部分&#xff0c;但事实上 UTXO 和区块链没有必然的联系&#xff0c;你可以完全照搬比特币区…

UT单元测试(一)——基础流程总结篇

参考书籍《单元测试的艺术》 一、单元测试的定义 一个单元测试是一段代码&#xff08;通常是一个方法&#xff09;&#xff0c;这段代码调用另一段代码&#xff08;一个单元可以是一个方法或函数&#xff09;&#xff0c;然后检验某些假设的正确性。如果这些假设是正确的&a…

UT标记详细说明

原来论坛用的是UT标记&#xff0c;UT是UltraThreads的简写。 微软word用的是Microsoft Word XML。 网页用的html ------------------------------------------------------------------ 什么是UT代码&#xff1f; UT标记对HTML的简化。一般情况下&#xff0c;即使指定讨论区禁…