python3.8.5怎么用-python3.8 五分钟就可以入门
嗨大成带你五分钟入门 python编程语言
了解Python的语法(第一个hello world)
print('Hello world!') #打印Hello world
字符串格式
name = '嗨大成'
print('Hello, %s' % name) # Hello,嗨大成
print('Hello,{}'.format(name)) # string formatting #也是上面的 Hello,嗨大成
定义函数
def add_one(x):
return x + 1
测试
x = 1
y = 2
print( 'x is equal to y: %s' % (x == y))
z = 1
print ('x is equal to z: %s' % (x == z))
names = ['Donald', 'Jake', 'Phil']
words = ['Random', 'Words', 'Dogs']
if names == words:
print ('Names list is equal to words')
else:
print ("Names list isn't equal to words")
new_names = ['Donald', 'Jake', 'Phil']
print ('New names list is equal to names: %s' % (new_names == names))
定义类里面的2个函数
class Talker(object):
def greet(self, name):
print ('Hello, %s!' % name)
def farewell(self, name):
print ('Farewell, %s!' % name)
定义list
dynamic_languages = ['Python', 'Ruby', 'Groovy']
dynamic_languages.append('Lisp')
定义字典
numbered_words = dict()
numbered_words[2] = 'world'
numbered_words[1] = 'Hello'
numbered_words[3] = '!'
循环
while True:
if value == wanted_value: #判断条件
break
else:
pass
定义多行字符串
string = '''This is a string with embedded newlines.
Also known as a tripled-quoted string.
Whitespace at the beginning of lines is included,
so the above line is indented but the others are not.
'''
源代码上拆分长字符串
string = ('This is a single long, long string'
' written over many lines for convenience'
' using implicit concatenation to join each'
' piece into a single string without extra'
' newlines (unless you add them yourself).')
循环
for x in xrange(1, 4):
print ('Hello, new Python user!'
'This is time number %d') % x
列表
l = [x**2 for x in range(4)]
print(l)
# [0, 1, 4, 9]
有条件的
squares = {x**2 for x in [0,2,4] if x < 4}
print(squares)
# {0, 4}
python3.8.5怎么用-python3.8 五分钟就可以入门相关推荐
- 五分钟you-get入门
title: 五分钟you-get入门 date: 2022-02-19 14:00:00 categories: python description: python you-get 1. You- ...
- markdown 本地链接_五分钟快速入门Markdown
前言 开篇第一问,什么是markdown?我为什么选择用它而不是用word? markdown是一种极为简洁的标记语言,使用markdown可以更集中于写作内容本身而不必过分纠结于格式排版问题,可以把 ...
- Spring Data JPA 五分钟快速入门和实践
Spring Data JPA(类似于Java Web 中的 DAO) 操作声明持久层的接口(Repository) 三个核心接口: CrudRepository PagingAndSortingRe ...
- 五分钟快速入门 Spring Data JPA
Spring Data JPA(类似于Java Web 中的 DAO) 操作声明持久层的接口(Repository) 三个核心接口: CrudRepository PagingAndSortingRe ...
- Palo Doris版五分钟快速入门
本文转载自百度开发者中心https://developer.baidu.com/article/detail.html?id=294225 在本教程章节中,我将为大家介绍使用Palo UI快速体验和使 ...
- java对象转xml jackson_五分钟Jackson入门(三) JSON数据类XML转换(附项目源码)
JSON数据看起来就像一棵树,也可以用类似于XML的解析方法来解析.将上篇文章的Demo改为: package com.hankcs; import org.codehaus.jackson.Json ...
- 两个案例五分钟轻松入门Harmony(鸿蒙)开发
一.任务说明 构建一个简单的具有页面跳转功能的应用,以此来熟悉HarmonyOS应用开发流程!HarmonyOS提供了两种FA(Feature Ability)的UI开发框架:Java UI框架和JS ...
- Koala五分钟快速入门
2019独角兽企业重金招聘Python工程师标准>>> Koala介绍 关于Koala平台更多的详细内容请访问:http://openkoala.org/ Koala Plugin的 ...
- B 站神曲damedane:精髓在于换脸,五分钟就能学会
导读:AI 换脸技术层出不穷,但一代更比一代强.最近,一个发表在 NeurIPs 2019 的 AI 换脸模型 first order motion model 火了起来,其表情迁移效果胜过同领域其它 ...
最新文章
- 测试报告-1.1组成和要点
- Groovy与Java的不同点
- C/C++中near和far的区别
- java jdbc 增删改封装_JAVA JDBC 常规增删改查简单封装
- 美团工程师回应“频繁定位”:常用App权限开启时检测结果基本一致
- C4D双十一促销海报模板,参考一下!
- 无代码来了,还要程序员吗?
- Edit Control最简单使用
- Java小游戏 超级玛丽源码分享
- FeHelper工具(Web前端助手)
- 版本控制软件Git的使用(小白版)
- nginx 连接php
- 2021年安全员-C证(陕西省)考试资料及安全员-C证(陕西省)免费试题
- 第三方支付网关的选择
- Base64 编码原理及代码实现
- Camera成像原理(raw图如何产生的)
- Ubuntu 下Android开发环境搭建
- 2022年值得关注的 8 个人工智能趋势及中国人工智能行业发展情况
- linux while 多个条件,Shell语法—— while 条件语句
- 二战浙大失利+调剂科大教训帖