python基础知识
来源:互联网 发布:网络空间用什么来描绘 编辑:程序博客网 时间:2024/06/05 15:14
!/usr/bin/python
-- coding: UTF-8 --
import calendar
import time
列表
list1 = [“sdf”,”sdff”,”sdfdd”]
print list1[1]+”\n”
元组 元组与列表类似,不同之处在于元组的元素不能修改
tup1 = (‘physics’, ‘chemistry’, 1997, 2000);
print tup1[0]+”\n”
字典Dictionary(map)
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
print “dict[‘Name’]: “, dict[‘Name’]
print “dict[‘Age’]: “, dict[‘Age’]
输出当前时间
tim = time.strftime(“%Y-%m-%d %H:%M:%S”, time.localtime())
print tim
print tim.split(” “)[0]
输出月份日历
cal = calendar.month(2017, 6)
print “以下输出2016年1月份的日历:”
print cal;
while循环
count = 0
while (count < 9):
print ‘The count is:’, count
count = count + 1
for循环 str可以为字符串,列表,字典等
str = “spark”
for i in str:
print i
字典遍历
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
for i in dict.items():
print i[0]
print i[1]
dict1 = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
for i in dict1.keys():
print i
print dict1[i]
- python基础知识
- Python 基础知识
- Python 基础知识
- python基础知识
- python基础知识
- python基础知识
- python基础知识
- Python基础知识
- python基础知识
- python基础知识
- Python-基础知识
- python基础知识
- python基础知识
- Python基础知识
- python基础知识
- python基础知识
- python基础知识
- Python:基础知识
- 时间空间复杂度(二分查找和斐波那契数列)
- java中自动往邮箱里发送网页时的要求
- spring boot 集成druid,监控配置
- 套接字编程(一)----基于TCP协议
- 二级域名配置(万网 + tomcat8.5) 解析到子目录
- python基础知识
- Python爬虫简单实战:抓取小猪短租西安市前五页民房数据
- 532. K-diff Pairs in an Array
- WPF NotifyIcon ContextMenu 右键菜单 样式Style
- 大学计算机模拟考试常见试题与解析(二)
- 语言,框架等等工具的选择
- 乘积最大
- 2017的OI之路的梦想
- Conway's law