随笔- 153
文章- 0
评论- 18
阅读-
50万
随笔分类 - Python
Python利用psycopg2对PostgreSQL进行DML
摘要:#!/usr/local/python3/bin/python import sys import os import psycopg2 DB_HOST = "172.16.101.54" DB_PORT = 5432 DB_USER = "dbadmin" DB_PASSWORD = "agm43
阅读全文
python类学习
摘要:创建关于汽车的类 输出 Toyota is a popular automobile brand. Its headquater is in Japan. 列子 输出 There is a restaurant called Xianghui Xin, its cuisine is Xiang Cu
阅读全文
python函数学习
摘要:函数定义和简单调用 公司新来部分新员工,定义函数并循环打印欢迎新员工的消息 输出 Welcome our new colleague Chris, his post is NOC ! Welcome our new colleague David, his post is PJM ! Welcome
阅读全文
python while循环
摘要:循环打印1~5 i = 1 while i <= 5: print(i) i += 1 输出 1 2 3 4 5 View Code 循环执行判断用户输入,若输入quit就退出循环 prompt = "Please enter 'quit' to logoff program: " message
阅读全文
字典、列表之间相互嵌套
摘要:列表中嵌套字典 employee_1 = {'name': 'david', 'dept': 'ops', 'post': 'NOC', 'salary': 12000, 'id': 113} employee_2 = {'name': 'brain', 'dept': 'auto', 'post'
阅读全文
python字典
摘要:字典即为放在花括号{}中一系列键值对的集合,值可以使数字、字符、集合等。 字典创建 >>> employee_1 = {'name': 'david', 'dept': 'ops', 'post': 'NOC', 'salary': 9999} >>> >>> type(employee_1) <c
阅读全文
python列表和if语句的简单结合
摘要:将列表所有元素打印出来 cars = ['toyota', 'honda', 'mazda', 'nissan', 'mitsubishi', 'subaru', 'suzuki', 'isuzu'] for car in cars: new_car = car.title() print("Jap
阅读全文
python列表的切片与复制
摘要:切片,即处理一个完整列表中部分数据。 语法 变量[起始索引:终止索引:步长] 首先创建一个字符串列表 >>> cars = ['toyota', 'honda', 'mazda', 'nissan', 'mitsubishi', 'subaru', 'suzuki', 'isuzu'] >>> >>
阅读全文
python数值列表
摘要:使用range函数生成数值列表 使用range函数打印1~5的数字 for i in range(1,6): print(i) 输出 1 2 3 4 5 View Code 利用range函数生成数值列表 >>> numbers = list(range(1,6)) >>> >>> type(num
阅读全文
python列表
摘要:列表定义:列表是以逗号为分割单位的按照特定顺序排列的一系列字符串,以方括号[]为标识,方括号[]内每个逗号分隔的字符串称为元素。 列表增删改查 新建列表 新建名称为cars的列表 >>> cars = ['toyota', 'honda', 'mazda', 'subaru', 'suzuki']
阅读全文