博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【python3的学习之路一】输入和输出
阅读量:7240 次
发布时间:2019-06-29

本文共 1015 字,大约阅读时间需要 3 分钟。

标识符

  • 第一个字符必须是字母或下划线
  • 标识符的其他的部分由字母、数字和下划线组成
  • 标识符对大小写敏感

Python保留字

即关键字,不能把它们用作任何标识符名称

>>> import keyword>>> keyword.kwlist['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

多行语句

Python通常一行写完一条语句,但如果语句过长,我们可以使用反斜杠来实现多行语句

total = 'item_one' + \    'item_two' + \    'item_three'

同一行显示多条语句

Python可以在同一行中使用多条语句,语句之间使用分号(;)分割

total = 'item_one' + \    'item_two' + \    'item_three';print(total)

输出

用 print() 在括号中加上字符串,就可以向屏幕输入指定的文字。同时print()函数也可以接受多个字符串,采用逗号隔开的方式就可以连成一串输出(遇到逗号会输出一个空格)。

print('Hello world!')print('Hi,', 'what is your name?', 'Bye!')

关键字end可以用于将结果输出到同一行,或者在输出的末尾添加不同的字符

print(str, end = ',')print(str, end = ' ')

输入

input()函数可以让用户输入字符串,并存放到一个变量里。

name = input()age = input('How old are you?')print(name, 'is', age, 'years old!')

转载于:https://www.cnblogs.com/CSgarcia/p/9705759.html

你可能感兴趣的文章
CYQ.Data 从入门到放弃ORM系列:开篇:自动化框架编程思维
查看>>
在设计DJANGO用户更改密码时,出现NoReverseMatch at /account/password-change/这种妖精如何办?...
查看>>
android中保存一个ArrayList到SharedPreferences的方法
查看>>
NOIP模拟赛20161016R1
查看>>
SQL Server 常用命令
查看>>
ElasticSearch插件安装Head、Kopf与Bigdesk
查看>>
安卓开发必备知识体系:安卓篇
查看>>
python列表推导式详解 列表推导式详解 字典推导式 详解 集合推导式详解 嵌套列表推导式详解...
查看>>
What's the difference between @Component, @Repository & @Service annotations in Spring?
查看>>
Android 开发中 iBeacon的使用
查看>>
分布式搜索引擎Elasticsearch的查询与过滤
查看>>
Docker Network containers
查看>>
(转) How to Train a GAN? Tips and tricks to make GANs work
查看>>
CMS系统的实现图
查看>>
软件门外汉的入门进阶
查看>>
360度舵机和180度舵机控制方法小结(转)
查看>>
Disable Maven Nature和disable workspace resolution
查看>>
mysql大数据量分页查询优化
查看>>
JS框架设计之对象扩展一种子模块
查看>>
ONVIF Device Manager v2.2.146
查看>>