Python中文
首页
教程
问答
标签
搜索
登录
注册
AttributeError:“NoneType”对象没有属性“append”,无论是什么
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在(尝试)分析我的研究小组使用的软件的输出,到目前为止,我能够逐行迭代我需要的列表(好吧,在循环的末尾有一个小的烦人的空列表[])。当我试图将每次迭代中得到的列表附加到一个大列表(列表列表列表)中时,真正的问题就开始了,这样我就可以在循环之外处理它了。在</p> <p>到目前为止,代码如下:</p> <pre><code>vdf_file_path = "/home/henrique/Coding/Python/VEDA2XLSX/nq1a.vdf" vdf_big_list = [] vdf_s_lines_string = """ """ with open(vdf_file_path, "r") as vdf_all_input_lines: for vdf_line in vdf_all_input_lines.readlines()[4:]: if "Frequencies" in vdf_line: break else: vdf_s_line_fixed = vdf_line.strip() vdf_s_lines_list = list(filter(None,vdf_s_line_fixed.split(" "))) vdf_big_list = vdf_big_list.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(vdf_s_lines_list) </code></pre> <p>(请原谅我的混乱代码,我还在学习)</p> <p>然后我收到错误:</p> ^{pr2}$ <p>尽管阅读了<a href="https://stackoverflow.com/questions/13555551/attributeerror-nonetype-object-has-no-attribute-append">here</a>提供的答案并尝试了几种方法,但我仍然无法理解问题所在并解决它。在</p> <p>有什么建议吗?在</p> <p><strong>数据样本</strong>:</p> <pre><code>abbreviation of: e:\documents\yyyy\yyyyyy-yyyyyy\camb3lyp\dmso\veda\nq1a.ved IR spectrum from file: e:\Documents\yyyyyyy\yyyyyyyyy-yyyyyyyy\CAMB3LYP\dmso\Veda\nq1a.out diagonality factor = 53.06 <EPm> = 49.71 IR RAMAN CM-1 245.54 730.41 3538.10 s1 100 3.93 204.17 3237.13 s6 93 11.13 477.42 3233.43 s3 14 s5 76 3.44 136.83 3229.53 s3 -78 s5 15 262.17 212.10 1672.05 s16 61 117.64 169.79 1669.31 s17 -64 s41 14 9.66 60.78 1657.86 s19 -59 s44 10 981.59 1079.26 1642.51 s18 -56 1030.99 315.40 1578.03 s37 40 s42 10 185.95 27.40 1559.81 s37 20 s42 -37 55.61 10.42 1535.81 s39 -53 s63 14 4.91 5.16 1507.94 s20 -37 s40 44 59.12 24.29 1504.96 s47 69 s76 -23 14.09 29.85 1492.35 s46 -71 s75 22 19.97 9.49 1487.58 s48 86 17.93 4.37 1469.24 s21 -39 s43 -27 </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>发生这种情况是因为<code>append</code>的返回为None。 第一次追加时,<code>vdf_big_list</code>被指定为None。在</p> <p>将代码更改为</p> <pre><code>vdf_big_list.append(vdf_s_lines_list) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
python语法错误(如果不在Z中,则在X中表示s)
10 回答
Python语法错误(无效)概率
9 回答
python语法错误*带有可选参数的args
9 回答
python语法错误2.5版有什么办法解决吗?
2 回答
Python语法错误2.7.4
1 回答
python语法错误30/09/2013
2 回答
Python语法错误E001
2 回答
Python语法错误not()op
3 回答
python语法错误outpu
7 回答
Python语法错误print len()
2 回答
python语法错误w3
10 回答
Python语法错误不是caugh
7 回答
python语法错误及yt-packag的使用
2 回答
python语法错误可以查出来!!瓦里亚布
5 回答
Python语法错误可能是缩进?
4 回答
Python语法错误和缩进
5 回答
Python语法错误在while循环中生成随机numb
4 回答
Python语法错误在哪里?
1 回答
python语法错误在尝试导入包时,但仅在远程运行时
7 回答
Python语法错误在电子邮件地址提取脚本中
9 回答