意外错误,不适当的参数值(或正确的类型)
Unexpected error , Inappropriate Argument value ( or correct type)
请原谅我的格式不佳,这是我的第一个 post。
我只是想将我的列表设置为浮动并相应地显示。
但是我收到了这个错误代码。
The error was: 1.91.6
Inappropriate argument value (of correct type).
An error occurred attempting to pass an argument to a function.
Please check line 8 of F:\Inft1004\Assignment 1\NikGeorge_Assgt
heightData.txt 包含以下内容:
2.1
1.9
1.6
2.3
2.2
1.6
1.8
1.9
2.1
1.8
1.6
1.5
2.2
1.8
1.7
1.8
1.9
我不知道是什么原因造成的,我的代码如下。
def calculateStatisticsFrom():
fileName = "heightData.txt"
fullPathName = getMediaPath(fileName)
print fullPathName
file = open(fullPathName, "r")
floats = []
for each in file:
floats.append(float(each.strip()))
printNow(floats)
感谢您的帮助。我真的很感激。
这个答案在评论中有一些上下文。
尝试从头开始重新创建您的数据文件。原件可能有额外的字符或有奇怪的编码。您也可以尝试对新旧数据文件进行比较 (windiff),看看有什么不同。
您的导师可能希望您处理导致问题的任何原因。如果它是初学者课程,虽然这不太可能。该文件在 HTTP 下载中可能已被轻微损坏。
似乎 JES 正在捕获发生的异常并将错误消息替换为坦率地说不如原始 python 异常有用(更不用说其他 SO 成员不熟悉)的不同消息。要查看原始 python 异常消息,您可以暂时将有问题的行包装在 try except
块中并打印出异常消息。
例如
try:
floats.append(float(each.strip()))
except Exception, e:
print e
请原谅我的格式不佳,这是我的第一个 post。
我只是想将我的列表设置为浮动并相应地显示。
但是我收到了这个错误代码。
The error was: 1.91.6 Inappropriate argument value (of correct type). An error occurred attempting to pass an argument to a function. Please check line 8 of F:\Inft1004\Assignment 1\NikGeorge_Assgt
heightData.txt 包含以下内容:
2.1
1.9
1.6
2.3
2.2
1.6
1.8
1.9
2.1
1.8
1.6
1.5
2.2
1.8
1.7
1.8
1.9
我不知道是什么原因造成的,我的代码如下。
def calculateStatisticsFrom():
fileName = "heightData.txt"
fullPathName = getMediaPath(fileName)
print fullPathName
file = open(fullPathName, "r")
floats = []
for each in file:
floats.append(float(each.strip()))
printNow(floats)
感谢您的帮助。我真的很感激。
这个答案在评论中有一些上下文。
尝试从头开始重新创建您的数据文件。原件可能有额外的字符或有奇怪的编码。您也可以尝试对新旧数据文件进行比较 (windiff),看看有什么不同。
您的导师可能希望您处理导致问题的任何原因。如果它是初学者课程,虽然这不太可能。该文件在 HTTP 下载中可能已被轻微损坏。
似乎 JES 正在捕获发生的异常并将错误消息替换为坦率地说不如原始 python 异常有用(更不用说其他 SO 成员不熟悉)的不同消息。要查看原始 python 异常消息,您可以暂时将有问题的行包装在 try except
块中并打印出异常消息。
例如
try:
floats.append(float(each.strip()))
except Exception, e:
print e