页面“Python中包含UTF-8编码中文的列表或字典的输出”与“Cannot access Input/output error”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
 
第1行: 第1行:
 +
=trouble=
 
<pre>
 
<pre>
 +
内网机器 PHP的人 随便重启,然后机器再起来出事了
 +
ls /home
 +
cannot access Input/output error
  
在python2.7 下面一个包含中文字符串的列表(list)或字典,直接使用print会出现以下的结果:
+
和乱码
 +
d??????????  ? ?    ?        ?            ? home
  
dict = {"asdf": "我们的python学习"}
 
print dict
 
{'asdf': '\xe6\x88\x91\xe4\xbb\xac\xe7\x9a\x84python\xe5\xad\xa6\xe4\xb9\xa0'}
 
借助于python的json模块处理数据的dump操作
 
在输出处理好的数据结构的时候很不方便,需要使用以下方法进行输出:
 
import json
 
print json.dumps(dict, encoding="UTF-8", ensure_ascii=False)
 
{"asdf": "我们的python学习"}
 
注意上面的两个参数
 
 
</pre>
 
</pre>
=参考=
+
=shooting=
[https://segmentfault.com/a/1190000002447836 python中包含UTF-8编码中文的列表或字典的输出]
+
<pre>
 +
lsof  | grep home
 +
有关home分区的程序先kill掉
 +
 
 +
 
 +
然后关掉机器 ,再硬重启 
 +
如果不行就得 
 +
fsck
 +
 
 +
例如如果上面的 /home  at  /dev/sda1
 +
1.应该是采用  修复命令  fsck 
 +
fsck -s /dev/sda1
 +
意外断电导致/dev/sda1分区的文件系统崩溃,所以针对这个分区进行修复,如果其他分区也出现类似情况,可以进行全盘修复
 +
  
[https://www.jianshu.com/p/5a23cb99aced Python中包含UTF-8编码中文的列表或字典的输出]
+
2.机器重启
  
[https://segmentfault.com/q/1010000004294086 python 字典中有中文写入文件后变成编码]
 
  
[[category:python]]
+
</pre>
 +
=see also=
 +
[https://unix.stackexchange.com/questions/39905/input-output-error-when-accessing-a-directory “Input/output error” when accessing a directory]
 +
 
 +
[https://www.cnblogs.com/Alanf/p/7509268.html cannot access Input/output error]

2020年2月18日 (二) 08:27的版本

trouble

 内网机器 PHP的人 随便重启,然后机器再起来出事了 
ls /home 
cannot access Input/output error

和乱码
d??????????   ? ?    ?        ?            ? home

shooting

lsof  | grep home 
有关home分区的程序先kill掉 


然后关掉机器 ,再硬重启  
如果不行就得  
fsck

例如如果上面的 /home  at  /dev/sda1
1.应该是采用  修复命令  fsck  
fsck -s /dev/sda1
意外断电导致/dev/sda1分区的文件系统崩溃,所以针对这个分区进行修复,如果其他分区也出现类似情况,可以进行全盘修复
 

2.机器重启 


see also

“Input/output error” when accessing a directory

cannot access Input/output error