Android开发的核心元素、Python使用内置模块获取类、方法以及参数
Android开发的核心元素
- Activity-A rectangular area that displays sth.
显示某个矩形区域。
onCreate()-the first method that will fire when an Activity is loaded
findViewById()-a way to locate resources in your Activity
- Intent-An action being requested that the device should try to perform
请求设备尝试执行的操作
getIntent()-gets the Intent that was passed to an Activity
获取传递给Activity的Intent
putExtra()-passes data as a key-value pair
getExtras().getString()-retrieved the String that was passed to the Intent object
startActivity()-used to launch another Activity
- IntentService-Services that can handle Intent requests and process the work to be done.
可以处理Intent请求并处理要完成的工作的服务。
- BroadcastReceivers-Receives an intent from a sendBroadcast method often indicating that some work has been completed.
从sendBroadcast方法接收Intent,通常表示某些工作已完成。
用python生成激活码并存入MySQL数据库
1 | # -*- coding: utf-8 -*- |
1 | def get_activation(): |
Python操作redis数据库,因为第一次接触redis数据库,所以详细写一下
首先是安装
1 | pip install redis |
阿里云centos中安装redis的全过程
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
cd /usr/local
mkdir redis
cd ~
tar -xzvf redis-5.0.5.tar.gz -C /usr/local/redis
cd /usr/local/redis/redis-5.0.5
make
cd /usr/local/redis/redis-5.0.5/src
cp {redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-rdb,redis-sentinel} /usr/local/bin
# 离开src目录
./utils/install_server.sh
chkconfig --list
/etc/init.d/redis_6379 start
/etc/init.d/redis_6379 stop
# 远程登录
cd /etc/redis
vim 6379.conf
Python使用内置模块获取类、方法以及参数
1 | clsmembers = inspect.getmembers(sys.modules[__name__], inspect.isclass) |
将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。 类似于图中效果
1 | from PIL import Image,ImageDraw,ImageFont |