题目:
n维矩阵没有做出来
读和写↓
def f_write():
file=open('erweijuzhen.txt','w')
row=int(input("请输入二维矩阵的行数\n"))
col=int(input("请输入二维矩阵的列数\n"))
for i in range(row):
for k in range(col):
num=int(input('输入%d个数字:\n'%(row*col)))
file.write(str(num)+',')
file.write('\n')
file.close()
f_write()
def f_read():
file=open('erweijuzhen.txt','r')
s='init'
while s!='':
s=file.readline()
print(s)
file.close()
f_read()
区分int,float,string↓
def isnum(a):
try:
int(a)
return'is int'
except:
try:
float(a)
return 'is float'
except:
return 'is string'
s=input("请输入字符:")
print(isnum(s))