第一章 输入输出与注释


前言

本文主要介绍python中的输入、输出与注释。

一、输出

1.print输出

#print number
print(12)
#print 字符
print("helloworld")
#print 运算表达式
print(3+2)
#不换行输出
print(2+3,'hello','world',65)

2.将数据输出于文件

fp=open('D:/document/教材/大四下/python学习/world.txt','a+')#文件不存在,创建文件,有文件,文件后写入东西
print('kello world',file=fp)
fp.close()

3.转义字符

#\n 换行;\r,回车;\t,水平制表符,注意制表位的占满与否;\b,退格。
print('hello\nworld')
print('hello\tw')
print('hellooo\tw')
print('hello\rworld')
print('hello\bworld')#退一个
#反斜杠\\,\'
print('hellohttp:\\www.com')
print('hellohttp:\\\\www.com')
print('老师说:\'大哥大\'')
#原字符:让转译字符无用,r
print(r'hellohttp:\\\\www.com')
#注意事项,最后一个字符不能是一个反斜线,两个反斜线
print('hellohttp:\\\\www.co\m')

二、输入与注释

1.input输入

#input()默认输入string类型变量
#input()其他类型输入与print类似
baba=input('爸爸的爸爸叫')
print(baba)

2.注释

#(这是单行注释)
'''
这
是
多
行
注
释
'''
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值