- 博客(162)
- 收藏
- 关注
原创 函数的定义和调用
# 定义函数def sum(a, b): c = a - b print(c)# 位置参数 按照位置一一对应的关系来传递参数sum(1,2)# 关键字传参sum(b=3,a=1)
2021-12-29 22:42:50
244
原创 字典遍历~
person = {'name':'张三','age':28,'学号':5}# 1遍历字典的KEY 字典.keys()就是获取字典中所有的keys值for key in person.keys(): #key 是变量的名,可以随意取 print(key)# 2遍历字典的VALUE 字典.values()就是获取字典中所有的values值for value in person.values(): print(value)# 3遍历字典的KEY和Valuefor a,b in pe.
2021-12-29 22:40:51
270
原创 字典删除~
# del# 1删除字典中指定的某一个元素# person = {'name':'张三','age':28}# print(person)# del person['age'] #如果KEY存在则直接删,如果不存在就报错# print(person)# 2删除整个字典# person = {'name':'张三','age':28}# print(person)# del person #整个person都删了.## clear# 3清空字典,但保留字典对象# pe.
2021-12-29 22:38:36
511
原创 字典添加~
person = {'name':'张三','age':28}print(person)# 如果使用变量名字['键'] = 值,这个键如果在字典中不存在,就会新增,存在则修改person['aa'] = 'bb'print(person)
2021-12-29 22:37:02
162
原创 字典修改~
person = {'name':'张三','age':28}print(person)person['name'] = '法外狂徒'person['age'] = 25print(person)
2021-12-29 22:33:56
181
原创 字典查询~
person = {'学号':5,'性别':'男'}## # 用[]访问字典中的元素 person[key值],如果key值不存在就会报错,如print(person['bb'])会报错# print(person['学号'])## # 用get来访问字典中的元素 person.get(key值),如果key值不存在则不会报错.只会返回None# print(person.get('学号'))# print(person.get('bb'))# C:\Python\Python37\p.
2021-12-26 18:01:59
343
原创 字符串切片
# s = 'hello world'## print(s)# print(s[4])# print(s[3:7]) #从下标3开始,左闭右开,就是[3,7) 即 lo w# print(s[2:]) #从下标2开始,没结束下标,就是到尾 即 llo world# print(s[:5]) #没写开始下标就是从头开始,左闭右开,就是[0,5) 即 hello# print(s[1:10:3]) #从下标1开始到下标10,步长为3 就是 [1,10) 即下标1,4,7 eoo# print.
2021-12-26 17:56:00
431
原创 元组~~~
# 元组中的元素不能被修改# a_tuple = (1,2,3,4,5)## print(a_tuple)# print(a_tuple[0])# print(a_tuple[4])# a_tuple = (5) 当元组中只有一个元素时,要加逗号,否则它就是int类型# print(type(a_tuple))# C:\Python\Python37\python.exe F:/program/python/lianxi/036_元组高级.py# <class 'int'>.
2021-12-26 17:51:31
95
原创 列表操作(删除)
# del 根据下标删除# pop 删除最后一个元素# remove 根据元素的值进行删除# a_list = [1,2,3,4,5,6]# print(a_list)# del a_list[3] # del list[下标] 根据下标删除# print(a_list)# C:\Python\Python37\python.exe F:/program/python/lianxi/035_列表高级_删除.py# [1, 2, 3, 4, 5, 6]# [1, 2, 3, .
2021-12-26 17:49:20
239
原创 列表操作(查询)
# fool_list = ['a','b','cc','dd']## # 判断在控制台输入的那个数据,是否在列表中## fool = input('请输入你想吃的食物')## if fool in fool_list:# print('有')# else:# print('没有')fool_list = ['a','b','cc','dd']fool = input('请输入你想吃的食物')if fool not in fool_list: print.
2021-12-26 17:48:20
247
原创 列表操作(修改)
# 通过列表的下标来进行修改fool_list = ['a','b','cc','dd']print(fool_list)fool_list[3] = 'ee'print(fool_list)
2021-12-26 17:46:03
354
原创 列表操作增加
# append 追加# fool_list = ['a','b','cc','dd']# print(fool_list)# fool_list.append('123')# print(fool_list)# C:\Python\Python37\python.exe F:/program/python/lianxi/032_列表高级_添加.py# ['a', 'b', 'cc', 'dd']# ['a', 'b', 'cc', 'dd', '123']## Process fini.
2021-12-26 17:43:10
208
原创 字符串~~~
# 获取长度 len len函数可以获取字符串的长度# 查找内容 fine 查找指定内容在字符串中是否存在,如果存在就返回在字符串中第一次出现的位置# 判断 startswith,endswith 判断字符串是不是以xxx开头/结尾# 计数出现次数 count 返回str在start和end之间,在mystr里面出现的次数# 替换内容 replace 替换字符串中指定的内容,如果指定次数count,则替换不会超过count次# 切割字符串 split .
2021-12-26 17:38:31
179
原创 for_range
# for格式 : for 变量 in 要遍历的数据# 方法体# s = 'china'# i 是字符串中一个又一个的字符变量# s 代表的是要遍历的数据# for i in s:# print(i)# range(5) [0,5) range从0开始# range方法的结果 一个可以遍历的对象# for i in range(5):# print(i)# range(1,6)# range(从哪开始挑,结束值) range从0.
2021-12-26 17:35:54
145
原创 寄存器的位带地址
如:端口A的第6个引脚GPIOA_6=0x42000000+(GPIOA->ODR - 0x40000000)*8*4+6*4=0x42000000+((AHB1PERIPH_BASE+0x0000+0x14)-0x40000000)*8*4+6*4=0x42000000+((PERIPH_BASE + 0x00020000+0x0000+0x14)-0x40000000)*32+24=0x42000000+((0x40000000)+0x00020000+0x0000+...
2021-09-23 22:30:45
1161
原创 STM32下载程序 (以F407VET6为例)
线路图代码#include "stm32f4xx.h" // Device headerGPIO_InitTypeDef GPIO_InitStructure;void delay(void){ uint32_t i = 0x200000; while(i--);}int main(void){ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE); GPIO_InitStru.
2021-09-20 14:37:14
3297
原创 STM32新建工程以F407VET6为例
#include "stm32f4xx.h" // Device headerint main(void){ while(1) { }}添加main函数后进行编译,这时候会有很多警告..需要添加宏定义....加完后再编译就没有问题了.附 : STM32F4xx_DSP_StdPeriph_Lib_V1.8.0.zip链接:https://pan.baidu.com/s/1Z_bmGREjJIZ9T4fjBi...
2021-09-20 11:53:17
4137
原创 8x8led点阵
#include <STC89C5xRC.H>/*-- 调入了一幅图像:这是您新建的图像 --*//*-- 宽度x高度=8x8 --*/unsigned char image[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C, 0x00,0x66,0xFF,0xFF,0xF...
2021-04-03 13:01:40
1940
原创 按键扫描测试
#include <STC89C5xRC.H>unsigned char KeySta[3][4] = { {1,1,1,1}, {1,1,1,1}, {1,1,1,1} };unsigned char code LedChar[]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x6f,0x3f,0x77,0x7C,0x39,0x5E,0x79,0x...
2021-03-27 17:18:23
263
原创 动态数码管秒计时
#include <STC89C5xRC.H>unsigned char code LedChar[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x6f,0};unsigned char ledbuff[] = {0,0,0,0,0,0,0,0};unsigned int cnt = 0;unsigned long sec = 0;unsigned char i = 0;unsigned char d = 0;void m...
2021-03-17 22:43:06
691
原创 整数拆分
#include <stdio.h>int main(void){ int x,temp; int mask = 1; scanf("%d",&x); temp = x; while(temp>9) { temp /= 10; mask *= 10; } printf("mask=%d\n",mask); while(mask>0) { .
2020-12-09 22:40:40
126
原创 2020-11-28增删改查基础
#include<stdio.h>#include<string.h>//定义结构体类型struct Customer{ int id; int age; char name[10]; char gender; char phone[16]; char email[20];};int loop = 1;char key;int customerNum = 1;struct Customer customers[100];void getCus.
2020-11-28 16:44:15
171
原创 2020-10-27冒泡程序bubbleSort
#include<stdio.h>//冒泡程序bubbleSort(由小到大排序)void bubbleSort(int arr[],int Len){ int i,j,temp; for(i=0;i<Len;i++) { for(j=0;j<Len-1;j++) { if(arr[j]>arr[j+1]) { temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; .
2020-10-27 22:53:48
140
原创 时间戳互转
时间戳[root@localhost ~]# date -d "1970-01-01 18098 days"2019年 07月 21日 星期日 00:00:00 CST根据日期得到时间戳[root@localhost ~]# echo $(($(date --date="2019/07/21" +%s)/86400+1))18098[root@localhost ~]#...
2019-12-11 23:04:47
135
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人