随笔分类 -  python

摘要:## 1. 示例 ``` message = input("tell me something, and I will repeat it back to you: ") print(message) ``` #### 1.1 提示 - prompt ``` prompt = "If you tel 阅读全文
posted @ 2023-07-08 10:43 钱塘江畔 阅读(48) 评论(0) 推荐(0)
摘要:## 1. 字典列表 ``` alien_0 = {'color': 'green', 'points':5} alien_1 = {'color': 'yellow', 'points':10} alien_2 = {'color': 'red', 'points':15} aliens = [a 阅读全文
posted @ 2023-07-07 18:35 钱塘江畔 阅读(32) 评论(0) 推荐(0)
摘要:## 1.示例 ``` alien_0 = {'color':'green', 'points':5} print(alien_0['color']) print(alien_0['points']) ``` ## 2.使用字典 字典就是一系列**键值对**,每个键与一个值相关联,可以通过键来访问相 阅读全文
posted @ 2023-07-07 17:53 钱塘江畔 阅读(16) 评论(0) 推荐(0)
摘要:## 1. 示例 ``` cars = ['audi', 'bmw', 'subaru', 'toyota'] for car in cars: if car == 'bmw': print(car.upper()) else: print(car.title()) ``` ## 2. 条件测试 布 阅读全文
posted @ 2023-07-07 15:43 钱塘江畔 阅读(57) 评论(0) 推荐(0)
摘要:[引用](https://blog.csdn.net/lyfGeek/article/details/106592636) 阅读全文
posted @ 2023-07-07 00:16 钱塘江畔 阅读(14) 评论(0) 推荐(0)
摘要:普通列表中的元素值可以改变,要创建元素值不可变的列表,就要使用**元组**。 不同之处是使用`()`,而非`[]`。 ## 元组的使用 使用方式和列表基本一致 ``` # 遍历元组 tuple = (1, 'a', 'element', 3.02, True) for element in tupl 阅读全文
posted @ 2023-07-07 00:01 钱塘江畔 阅读(13) 评论(0) 推荐(0)
摘要:## 1. 遍历列表 ``` magicians = ['alice', 'david', 'carolina'] print(magicians) # for循环 for magician in magicians: print(magician) for magician in magician 阅读全文
posted @ 2023-07-06 23:43 钱塘江畔 阅读(21) 评论(0) 推荐(0)
摘要:列表由一系列按特定顺序排列的元素组成。 ``` # 列表中可存放不同数据类型的数据 list = [1, 'a', 'element', 3.02, True] print(list) # 列表中存放数据类型相同的数据 bicycles = ['trek', 'cannondale', 'redli 阅读全文
posted @ 2023-07-06 21:58 钱塘江畔 阅读(15) 评论(0) 推荐(0)
摘要:## 1. 变量命名 > 变量名只能包含字母、数字和下划线。变量名不能以数字开头。 > 变量名不能包含空格,可使用下划线 > python关键字和函数名不能用作变量 > 慎用1和大写O > 变量名默认用小写字母表示 ## 2. 多个变量同时赋值 ``` x,y,z = 1, 2, 3 print(f 阅读全文
posted @ 2023-07-05 19:27 钱塘江畔 阅读(44) 评论(0) 推荐(0)
摘要:## 1. 整数 ``` # + - * / % 2 + 3 # 乘方 3 ** 2 (2 + 3) * 4 ``` ## 2. 浮点数 ``` # 精度有误 0.2 + 0.1 ``` ## 3. 整数和浮点数 ``` # 除的结果总是浮点数 4/2 # 其他运算,一个整数一个浮点数,结果也是浮点 阅读全文
posted @ 2023-07-05 19:12 钱塘江畔 阅读(13) 评论(0) 推荐(0)
摘要:## 1.字符串函数 ``` name = "james jacKSON" name.title() # 字符串首字母大写,其余字母变小写 name.upper() name.lower() ``` ## 2.在字符串中使用变量 - f字符串 (Python3.6引入的) ``` first_nam 阅读全文
posted @ 2023-07-05 18:38 钱塘江畔 阅读(13) 评论(0) 推荐(0)
摘要:## 1.背景 内网服务器不能直接连接外网,但是需要Python的mysql-connector-2.1.7包 ## 2.步骤 ``` # 下载相关tar包 https://pypi.doubanio.com/simple/mysql-connector/mysql-connector-2.1.7. 阅读全文
posted @ 2023-06-06 12:39 钱塘江畔 阅读(380) 评论(0) 推荐(0)
摘要:[Python MySQL - mysql-connector 驱动](https://blog.csdn.net/weixin_44304678/article/details/126082194) 阅读全文
posted @ 2023-05-30 18:18 钱塘江畔 阅读(18) 评论(0) 推荐(0)
摘要:pandas Pandas语法大全 pandas基础语法 Pandas数据转换处理 pandas——取matrix中的某些数据 阅读全文
posted @ 2023-04-27 20:49 钱塘江畔 阅读(19) 评论(0) 推荐(0)
摘要:安装Anaconda之后,进行jupyter安装 pip install jupyterlab 报错解决 pip is configured with locations that require TLS/SSL, however the ssl module in Python is not pi 阅读全文
posted @ 2023-03-03 13:01 钱塘江畔 阅读(90) 评论(0) 推荐(0)
摘要:win11安装Anaconda Linux下安装Anaconda3 阅读全文
posted @ 2023-03-03 12:44 钱塘江畔 阅读(19) 评论(0) 推荐(0)