python 语法基础
来源:互联网 发布:网络推广专员面试 编辑:程序博客网 时间:2024/06/14 07:56
输入输出:
name = input('Your name:')print('hello {}'.format(name))
文本划分:
sample = "john,plastic,joe"split_list = sample.split(",")print(split_list)string_two = "How are you\nI'm fine\nThank you."split_string_two = string_two.split('\n')print(split_string_two)
条件分支:
grade = 59if grade > 90: print('A')elif grade > 75: print('B')elif grade > 60: print('C')else: print('D')
for循环:
cities = ["Austin", "Dallas", "Houston"]for city in cities: print(city)
while循环:
i = 0while i < 3: i += 1 print (i)
f = open("test.txt", "r")g = f.read()print(g)f.close()
f = open("test_write.txt", "w")f.write('123456')f.write('\n')f.write('234567')f.close()
List使用:
countries = []countries.append("China")countries.append("India")countries.append("United States")print (countries)c = countries[1]print (c)
scores = {} print (type(scores))scores["Jim"] = 80scores["Sue"] = 85scores["Ann"] = 75print (scores)print (scores["Sue"])
阅读全文
0 0
- 【python】python语法基础
- Python基础语法学习
- Python 基础语法知识
- Python基础语法
- python 基础语法
- Python基础语法
- python语法 -- 基础篇
- Python 语法基础
- Python基础语法
- Python 基础语法(一)
- Python 基础语法(二)
- Python基础语法
- Python基础语法
- Python基础语法笔记
- Python 基础语法(一)
- Python 基础语法
- Python基础语法学习
- Python 基础语法(1)
- ServletConfig和ServletContext的意思
- 无缝滚动效果
- 【DBSDFZOJ 4460】666(DP)
- 服务器硬件选型标准之一
- bzoj1391最大闭合权图
- python 语法基础
- PAT 甲级 1098. Insertion or Heap Sort (25)
- 进程和线程的差别
- Airflow安装教程
- 高精模板
- Java基础之抽象类和接口
- 基于selenium和requests的京东商品信息和评论爬虫
- NOIP2009靶形数独(DFS)
- Linux下CMake 安装教程