标签:coding file inpu git 占位符 输出 else author ring
实例# -*-coding:utf-8 -*-
__date__ = ‘2018/2/6 15:19‘
__author__ = ‘xiaojiaxin‘
__file_name__ = ‘string1‘
a=input()
if a.isdigit():
print(a)
print(type(a))
else:
print("not digit!")
输入:1d
not digit!
输入:200
200
<class ‘str‘>
字符格式化输出:
占位符:
%s string
%d digit
%f float
name="a"
grade=98
avg1=90.5
print(name,grade,avg1,type(name),type(grade),type(avg1))
print("my name is %s"%name)
print("my name is %s,my grade is %d,avg is %f"%(name,grade,avg1))
a 98 90.5 <class ‘str‘> <class ‘int‘> <class ‘float‘>
my name is a
my name is a,my grade is 98,avg is 90.500000
标签:coding file inpu git 占位符 输出 else author ring
原文地址:http://blog.51cto.com/10777193/2069602