'''
@author: Riquelqi
'''
#!/user/bin/env python
import os
ls=os.linesep
def write():
content=[]
#Input a filename.
fname=raw_input("Please input a filename:%s"%ls)
print "Please input content(Quit with 'q'):"
lines=raw_input(">")
while lines!="q":
content.append(lines)
lines=raw_input(">")
afile=open(fname,"w")
afile.writelines("%s%s"%(line,ls)for line in content)
afile.close()
print "DONE!",
def read():
#input a filename
fname=raw_input('Please input a filename:%s'%ls)
#To be sure that the file path exists
if not os.path.exists(fname):
print"File doesn't exists!"
else:
afile=open(fname,'r')
for line in afile.readline():
print line,
print '\nDONE!'
if __name__=='__main__':
input=raw_input("""
|Please input your commend|
--|-------------------------|--
--| r | read |--
--| w | write |--
--| q | quit |--
|Please input your commend|
""" )
while input!='q':
if input=='r':
read()
elif input=='w':
write()
input=raw_input("""
|Please input your commend|
--|-------------------------|--
--| r | read |--
--| w | write |--
--| q | quit |--
|Please input your commend|
""" )
'''
@author: Riquelqi
'''
# To import like this is better than import types ,because we will use the property like that types.IntType...
# It will select twice
from types import IntType,FloatType,LongType,ComplexType
def display_Number_Best(number):
print number, 'is',
if isinstance(number,(int,long,float,complex)):
print 'a number of type:',type(number).__name__
else:
print 'not a number at all',
def display_Number_Worst(number):
print number,'is'
if type(number)==type(0):
print 'a number of type:',type(0).__name__
elif type(number)==type(0L):
print 'a number of type:',type(0L).__name__
elif type(number)==type(0.0):
print 'a number of type:',type(0.0).__name__
elif type(number)==type(0.0+0.0j):
print 'a number of type:',type(0.0+0.0j).__name__
else :
print 'not a number at all'
def display_Number_Better(number):
print number,'is'
if type(number) is IntType:
print 'a number of type: int'
elif type(number) is FloatType:
print 'a number of type:float'
elif type(number) is LongType:
print 'a number of type:Long'
elif type(number) is ComplexType:
print 'a number of type:Complex'
else:
print 'not a number at all'
def display_Number_Good(number):
print number,'is'
if type(number) == IntType:
print 'a number of type: int'
elif type(number) == FloatType:
print 'a number of type:float'
elif type(number) == LongType:
print 'a number of type:Long'
elif type(number) == ComplexType:
print 'a number of type:Complex'
else:
print 'not a number at all'
if __name__=='__main__':
display_Number_Best(94)
display_Number_Best(-64)
display_Number_Best(10.3232)
display_Number_Best(777777777777777777777777)
display_Number_Best(10.0+10.0j)
display_Number_Best('qq')
# display_Number_Worst(554454)
# display_Number_Worst(10.11)
# display_Number_Worst(10.0+10.0j)
# display_Number_Worst("sdfsdfsd")
# display_Number_Better(45654)
# display_Number_Better(10.0)
# display_Number_Better(10.0+10.0j)
# display_Number_Better(8888888888888888)
# display_Number_Better('xxx')
# display_Number_Good(21554)
# display_Number_Good(8888888888888888888888888)
# display_Number_Good(10.0)
# display_Number_Good(10.0+10.0j)
# display_Number_Good('my')