广播

1.什么是广播        

2.标准广播

BroadStandardActivity.java

package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;import com.tiger.chapter09.receiver.StandardReceiver;public class BroadStandardActivity extends AppCompatActivity implements View.OnClickListener {private StandardReceiver standardReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_broad_standard);findViewById(R.id.btn_send_standard).setOnClickListener(this);}@Overridepublic void onClick(View v) {//发送标准广播  相当于主题Intent intent = new Intent(StandardReceiver.STRING);sendBroadcast(intent);}@Overrideprotected void onStart() {super.onStart();standardReceiver = new StandardReceiver();//代表上下文 注册 广播接收者  相当于订阅IntentFilter intentFilter = new IntentFilter(StandardReceiver.STRING);//注册接收器,注册之后才能正常接收广播registerReceiver(standardReceiver,intentFilter);}@Overrideprotected void onStop() {super.onStop();//在Activity不用的时候就不需要 广播订阅了,先注销接收者unregisterReceiver(standardReceiver);}
}

xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"android:padding="5dp"><Buttonandroid:id="@+id/btn_send_standard"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:text="发送标准广播"android:textColor="@color/black"android:textSize="17sp" /></LinearLayout>

receiver

package com.tiger.chapter09.receiver;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;//定义一个标准广播的接收器
public class StandardReceiver extends BroadcastReceiver {public static final String STRING ="com.tiger.chapter09.standard";//一旦接收到标准广播,马上触发接收器的onReceive方法@Overridepublic void onReceive(Context context, Intent intent) {//先当于订阅主题if (intent!=null&&intent.getAction().equals(STRING)){Log.d("ning","收到了标准广播");}}
}

3.有序广播

 BroadOrderActivity.java

package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;import com.tiger.chapter09.receiver.OrderAReceiver;
import com.tiger.chapter09.receiver.OrderBReceiver;public class BroadOrderActivity extends AppCompatActivity implements View.OnClickListener {public static final String ORDER_ACTION = "com.tiger.chapter09.order";private OrderAReceiver orderAReceiver;private OrderBReceiver orderBReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_broad_order);findViewById(R.id.btn_send_order).setOnClickListener(this);}@Overridepublic void onClick(View v) {//创建一个指定动作的意图Intent intent  =new Intent(ORDER_ACTION);//发送有序广播sendOrderedBroadcast(intent,null);}@Overrideprotected void onStart() {super.onStart();//多个接收器处理有序广播的顺序规则为://1.优先级越大的2接收器,越早收到有序广播//2.优先级相同的时候,越早注册的接收器越早收到有序广播orderAReceiver = new OrderAReceiver();IntentFilter filterA = new IntentFilter(ORDER_ACTION);filterA.setPriority(8);registerReceiver(orderAReceiver,filterA);orderBReceiver = new OrderBReceiver();IntentFilter filterB = new IntentFilter(ORDER_ACTION);filterB.setPriority(10);registerReceiver(orderBReceiver,filterB);}@Overrideprotected void onStop() {super.onStop();unregisterReceiver(orderAReceiver);unregisterReceiver(orderBReceiver);}
}

AOrder

package com.tiger.chapter09.receiver;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;import com.tiger.chapter09.BroadOrderActivity;public class OrderAReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {if (intent!=null&&intent.getAction().equals(BroadOrderActivity.ORDER_ACTION)){Log.d("ning","接收器A 收到了有序广播");}}
}

BOrder

package com.tiger.chapter09.receiver;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;import com.tiger.chapter09.BroadOrderActivity;public class OrderBReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {if (intent!=null&&intent.getAction().equals(BroadOrderActivity.ORDER_ACTION)){Log.d("ning","接收器B 收到了有序广播");abortBroadcast();//中断广播,此时后面的接收器无法收到该广播}}
}

4.广播的静态注册

activity

package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;import com.tiger.chapter09.receiver.ShockReceiver;public class BroadStaticActivity extends AppCompatActivity implements View.OnClickListener {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_broad_static);findViewById(R.id.btn_send_shock).setOnClickListener(this);}@Overridepublic void onClick(View v) {//Android8.0 之后 删除了大部分静态注册,防止退出App后仍在接收广播//为了让应用能够继续接收静态广播,需要给静态注册的广播指定包名String fullName = "com.tiger.chapter09.receiver.ShockReceiver";Intent intent = new Intent(ShockReceiver.SHOCK_ACTION);ComponentName componentName = new ComponentName(this, fullName);intent.setComponent(componentName);sendBroadcast(intent);}
}

 ShockReceiver

package com.tiger.chapter09.receiver;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.util.Log;public class ShockReceiver extends BroadcastReceiver {public static final String SHOCK_ACTION="com.jmj.shock";@Overridepublic void onReceive(Context context, Intent intent) {if (intent!=null&&intent.getAction().equals(SHOCK_ACTION)){Log.d("ning","震动一下");//从系统服务中获取震动管理器Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);//震动需要权限,开启清单权限就不会报错了vb.vibrate(VibrationEffect.createOneShot(500,50));}}
}

清单文件 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"><!--    震动需要系统权限 --><uses-permission android:name="android.permission.VIBRATE"/><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/Theme.MyApplication"><receiverandroid:name=".receiver.ShockReceiver"android:enabled="true"android:exported="true"><intent-filter><action android:name="com.jmj.shock"/></intent-filter></receiver><activityandroid:name=".BroadStaticActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>

5.系统分钟到达广播

Activity

package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;public class SystemMinuteActivity extends AppCompatActivity {private TimeReceiver timeReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_system_minute);}@Overrideprotected void onStart() {super.onStart();//创建一个分钟变更的广播接收器timeReceiver = new TimeReceiver();IntentFilter filter = new IntentFilter(Intent.ACTION_TIME_TICK);registerReceiver(timeReceiver,filter);}@Overrideprotected void onStop() {super.onStop();unregisterReceiver(timeReceiver);}
}

TimeReceiver

package com.tiger.chapter09;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;public class TimeReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {if (intent!=null){Log.d("ning","收到一个分钟到达广播");}}
}

6.系统网络变更广播

SystemNetWorkActivity

package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;import com.tiger.chapter09.receiver.NetWorkReceiver;public class SystemNetWorkActivity extends AppCompatActivity {private NetWorkReceiver netWorkReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_system_net_work);}@Overrideprotected void onStart() {super.onStart();netWorkReceiver = new NetWorkReceiver();IntentFilter filter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");registerReceiver(netWorkReceiver,filter);}@Overrideprotected void onStop() {super.onStop();unregisterReceiver(netWorkReceiver);}
}

NetWorkReceiver

package com.tiger.chapter09.receiver;import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.NetworkInfo;
import android.os.Parcelable;
import android.util.Log;import com.tiger.chapter09.util.NetworkUtil;public class NetWorkReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {if (intent != null) {NetworkInfo networkInfo = intent.getParcelableExtra("networkInfo");// 收到一个网络变更广播,网络大类为MOBILE,网络小类为HSPA,网络制式为3G,网络状态为DISCONNECTED// 收到一个网络变更广播,网络大类为WIFI,网络小类为,网络制式为未知,网络状态为CONNECTEDString text = String.format("收到一个网络变更广播,网络大类为%s," +"网络小类为%s,网络制式为%s,网络状态为%s",networkInfo.getTypeName(),networkInfo.getSubtypeName(),NetworkUtil.getNetworkClass(networkInfo.getSubtype()),networkInfo.getState().toString());Log.d("ning", text);}}
}

NetWorkUtil

package com.tiger.chapter09.util;import android.telephony.TelephonyManager;public class NetworkUtil {// 获取数据连接的制式类型public static String getNetworkClass(int subType) {switch (subType) {case TelephonyManager.NETWORK_TYPE_GPRS:case TelephonyManager.NETWORK_TYPE_EDGE:case TelephonyManager.NETWORK_TYPE_CDMA:case TelephonyManager.NETWORK_TYPE_1xRTT:case TelephonyManager.NETWORK_TYPE_IDEN:return "2G";case TelephonyManager.NETWORK_TYPE_UMTS:case TelephonyManager.NETWORK_TYPE_EVDO_0:case TelephonyManager.NETWORK_TYPE_EVDO_A:case TelephonyManager.NETWORK_TYPE_HSDPA:case TelephonyManager.NETWORK_TYPE_HSUPA:case TelephonyManager.NETWORK_TYPE_HSPA:case TelephonyManager.NETWORK_TYPE_EVDO_B:case TelephonyManager.NETWORK_TYPE_EHRPD:case TelephonyManager.NETWORK_TYPE_HSPAP:return "3G";case TelephonyManager.NETWORK_TYPE_LTE:return "4G";case TelephonyManager.NETWORK_TYPE_NR:return "5G";default:return "未知";}}
}

 

7. alarm定时器广播

package com.tiger.chapter09.receiver;import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;public class AlarmReceiver extends BroadcastReceiver {public static final String ALARM_ACTION="com.tiger.chapter09.alarm";private Context mContext;public AlarmReceiver(Context mContext) {this.mContext = mContext;}@Overridepublic void onReceive(Context context, Intent intent) {if (intent != null&&intent.getAction().equals(ALARM_ACTION)){Log.d("ning","收到闹钟广播");sendAlarm();}}//发送闹钟广播的方法public void sendAlarm(){Intent intent = new Intent(ALARM_ACTION);// 创建一个用于广播的延迟意图// 针对 S+(版本 10000 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。// 强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 是可变的时才使用 FLAG_MUTABLEPendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_IMMUTABLE);// 从系统服务中获取闹钟管理器AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){// 允许在空闲时发送广播,Android6.0之后新增的方法alarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, 1000, pendingIntent);}else{// 设置一次性闹钟,延迟若干秒后,携带延迟意图发送闹钟广播(但Android6.0之后,set方法在暗屏时不保证发送广播,// 必须调用setAndAllowWhileIdle方法)alarmManager.set(AlarmManager.RTC_WAKEUP, 1000, pendingIntent);}// 设置重复闹钟,每隔一定间隔就发送闹钟广播(但从Android4.4开始,setRepeating方法不保证按时发送广播)
//        alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
//                1000, pIntent);}
}
package com.tiger.chapter09;import androidx.appcompat.app.AppCompatActivity;import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;import com.tiger.chapter09.receiver.AlarmReceiver;public class AlarmActivity extends AppCompatActivity implements View.OnClickListener {private AlarmReceiver alarmReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_alarm);findViewById(R.id.btn_alarm).setOnClickListener(this);}@Overridepublic void onClick(View v) {alarmReceiver.sendAlarm();}@Overrideprotected void onStart() {super.onStart();alarmReceiver = new AlarmReceiver(getApplicationContext());IntentFilter filter = new IntentFilter(AlarmReceiver.ALARM_ACTION);registerReceiver(alarmReceiver,filter);}@Overrideprotected void onStop() {super.onStop();unregisterReceiver(alarmReceiver);}
}

8.竖屏与横屏切换

 

package com.tiger.chapter09;import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;public class ChangeDirectionActivity extends AppCompatActivity {private TextView tv_monitor;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_change_direction);tv_monitor = findViewById(R.id.tv_monitor);Log.d("ning","onCreate");//只执行一次,在屏幕旋转之后}//在配置项变更是触发。比如屏幕方向发生变更等等@Overridepublic void onConfigurationChanged(@NonNull Configuration newConfig) {super.onConfigurationChanged(newConfig);switch (newConfig.orientation){case Configuration.ORIENTATION_PORTRAIT:tv_monitor.setText("当前屏幕为竖屏方向");break;case Configuration.ORIENTATION_LANDSCAPE:tv_monitor.setText("当前屏幕为横屏方向");break;default:break;}}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"><!-- 震动需要系统权限 --><uses-permission android:name="android.permission.VIBRATE" /><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/Theme.MyApplication"><receiverandroid:name=".receiver.ShockReceiver"android:enabled="true"android:exported="true"><intent-filter><action android:name="com.jmj.shock" /></intent-filter></receiver><activityandroid:name=".ChangeDirectionActivity"android:exported="true"android:configChanges="orientation|screenLayout|screenSize"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>

设置只能竖屏或者横屏

 <activityandroid:name=".ChangeDirectionActivity"android:exported="true"android:configChanges="orientation|screenLayout|screenSize"android:screenOrientation="portrait"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity>

screenOrientation = portrait | landscape

9.回到桌面和使用任务列表

 
package com.tiger.chapter09;import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.Rational;public class ReturnDesktopActivity extends AppCompatActivity {private DesktopReceiver desktopReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_return_desktop);//因为按了Home或任务键 所以要在onCreate 和 Destroy 来注册 广播 要不然,stop就监听不到了desktopReceiver = new DesktopReceiver();IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);registerReceiver(desktopReceiver,filter);}@Overrideprotected void onDestroy() {super.onDestroy();unregisterReceiver(desktopReceiver);}//在进入画中画模式或退出画中画模式时触发@Overridepublic void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, @NonNull Configuration newConfig) {super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);if (isInPictureInPictureMode){//进入了画中画模式Log.d("ning","进入了画中画模式");}else {//退出了画中画模式Log.d("ning","退出了画中画模式");}}//定义一个返回到桌面的广播接收器private class DesktopReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {if (intent != null && intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {//回到桌面或者切换到任务列表的主题广播String reason = intent.getStringExtra("reason");if (!TextUtils.isEmpty(reason)&& (reason.equals("homekey") || reason.equals("recentapps"))) {//Android 8.0 开始才提供画中画模式if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isInPictureInPictureMode()) {//进入画中画模式 创建画中画模式的参数构造器PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder();//设置宽高比例值,第一个参数表示分子,第二个参数表示分母// 下面的10/5 =2,表示画中画窗口的宽度是高度的两倍Rational rational = new Rational(10, 5);//宽 高 10 : 5builder.setAspectRatio(rational);//进入画中画模式enterPictureInPictureMode(builder.build());}}}}}}

清单文件 开启画中画支持

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"><!-- 震动需要系统权限 --><uses-permission android:name="android.permission.VIBRATE" /><applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/Theme.MyApplication"><receiverandroid:name=".receiver.ShockReceiver"android:enabled="true"android:exported="true"><intent-filter><action android:name="com.jmj.shock" /></intent-filter></receiver><activityandroid:name=".ReturnDesktopActivity"android:configChanges="orientation|screenLayout|screenSize"android:exported="true"android:screenOrientation="portrait"android:supportsPictureInPicture="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/521278.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

为什么不用 index 做 key?

“在 Vue 中&#xff0c;我们在使用 v-for 渲染列表的时候&#xff0c;为什么要绑定一个 key&#xff1f;能不能用 index 做 key&#xff1f;” 在聊这个问题之前我们还得需要知道 Vue 是如何操作 DOM 结构的。 虚拟DOM 我们知道&#xff0c;Vue 不可以直接操作 DOM 结构&am…

js小案例-表格隔行变色

运行效果: 代码演示: <!DOCTYPE html> <html><head><meta charset="utf-8" /><title>18-案例-表格隔行变色</title></head><body><table id="tab1" border="1" width="800" al…

北斗卫星引领智能油气管线革新

北斗卫星引领智能油气管线革新 现代化的油气管线系统已成为国家经济发展的重要基础设施&#xff0c;而北斗卫星则为这些管线注入了新的活力。北斗卫星作为中国自主研发的卫星导航定位系统&#xff0c;其准确度和稳定性在全球范围内享有盛誉。在智能化时代的背景下&#xff0c;…

【OpenGL实践02】glDrawElements的使用案例

目录 一、说明二、顶点顺序渲染和选择渲染2.1 基本方法函数2.2.顶点数据管理2.3 层级关系 三、测试EBO的代码四、总结五、后记 一、说明 我们常用的着色器绘制函数是glDrawArray和glDrawElements&#xff0c;glDrawArray我们已经使用的很熟练&#xff0c;不需要重提&#xff…

深入了解Python的eval函数:基础用法与潜在危险【第118篇—eval函数】

深入了解Python的eval函数&#xff1a;基础用法与潜在危险 在Python中&#xff0c;eval函数是一个强大而灵活的工具&#xff0c;它允许将字符串作为代码来执行。然而&#xff0c;虽然eval在某些情况下非常方便&#xff0c;但它也潜藏着一些潜在的危险&#xff0c;如果不小心使…

小火星露谷管理器 如何禁用管理器下载?

错误操作 当你在N网点击下载时&#xff0c;你可能会点击左边第一个按钮进行下载&#xff0c;如图&#xff1a; 然后你可能会看到这样的一个提示&#xff1a; 很多用户看着这个提示误以为小火星露谷管理器禁用了N网的下载。 正确操作 N网网页上的按钮MOD MANAGER DOWNLOAD翻…

海外IP代理应用:亚马逊使用什么代理IP?

代理IP作为网络活动的有力工具&#xff0c;同时也是跨境电商的必备神器。亚马逊作为跨境电商的头部平台&#xff0c;吸引了大量的跨境电商玩家入驻&#xff0c;想要做好亚马逊&#xff0c;养号、测评都需要代理IP的帮助。那么应该使用什么代理IP呢&#xff1f;如何使用&#xf…

这6个国产办公软件凭什么被推荐?是真的好用

在数字化时代&#xff0c;办公软件已经成为我们日常生活和工作中不可或缺的工具。近年来&#xff0c;国产办公软件凭借其高效、便捷的特点受到了广泛的好评。今天给大家分享6款备受推荐的国产办公软件&#xff0c;让你了解它们的优势和使用场景。 一、Listary&#xff1a;强大的…

Python数据分析库之pandera使用详解

概要 在数据科学和数据分析中,数据的质量至关重要。不良的数据质量可能导致不准确的分析和决策。为了确保数据的质量,Python Pandera 库应运而生。本文将深入介绍 Python Pandera,这是一个用于数据验证和清洗的库,并提供丰富的示例代码,帮助大家充分利用它来提高数据质量…

学生课程参与度的一些情况

喊口号 日常校园中不乏各式各样的口号和标语。 但是能否落实到实处&#xff0c;非常难以评定的。 以学生为中心 实际上&#xff0c;学生对于课程几乎没有任何选择权和掌控权。 1&#xff0c;课程并非是学生自己选择的&#xff0c;还是培养方案安排的。 2&#xff0c;课程教…

Python与Go代码转换库之grumpy使用详解

概要 在软件开发领域,Python 和 Go 是两种备受欢迎的编程语言,它们各自拥有独特的优势和特点。Python 以其简洁、易学和强大的生态系统而闻名,而 Go 则以其高效、并发和简洁的语法而受到广泛青睐。然而,在某些情况下,开发人员可能会希望将 Python 代码转换为 Go 代码,以…

k8s-生产级的k8s高可用(1) 24

高可用集群 实验至少需要三个master&#xff08;控制节点&#xff09;&#xff0c;一个可以使外部可以访问到master的load balancer&#xff08;负载均衡&#xff09;以及一个或多个外部节点worker&#xff08;也要部署高可用&#xff09;。 再克隆三台主机 清理并重启 配置两…