码迷,mamicode.com
首页 > 编程语言 > 详细

python入门8 输入输出

时间:2018-11-04 12:44:38      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:span   odi   字符串   i+1   code   换行   usr   输入输出   乘法口诀   

输入 input()

输出 print()

 

#coding:utf-8
#/usr/bin/python
"""
2018-11-03
dinghanhua
输入输出
"""

‘‘‘输出print‘‘‘
print(‘hello ‘) #结尾end默认换行
print(‘world‘)

print(‘hello ‘,end=‘\t‘) #制定end
print(‘world‘)

print(‘a‘,‘b‘,‘c‘,sep=‘-‘) #sep指定分隔符

 

‘‘‘打印乘法口诀表‘‘‘
for i in range(1,10):
    for j in range(1,i+1):
        if i==j:
            print(i, ‘*‘, j, ‘=‘, i * j,end=‘\n‘)
        else:
            print(i,‘*‘,j,‘=‘,i*j,end=‘\t‘)

 

‘‘‘输入input‘‘‘

i = input(‘输入整数‘)
print(type(i))  #不管输入什么都是字符串类型
print(int(i)+100)

 

python入门8 输入输出

标签:span   odi   字符串   i+1   code   换行   usr   输入输出   乘法口诀   

原文地址:https://www.cnblogs.com/dinghanhua/p/9903375.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!