python的读入为何这么慢?
巴扎黑
巴扎黑 2017-04-18 10:34:17
0
0
359

python的读入处理麻烦,之前一直用的raw_input的方式,比如以空格分割的数据
23 2 8 8 13
我基本都是用temp = raw_input().split(‘ ’)来实现的,然后根据需要再转为int或者其他的类型
但是在实际中发现这类输入方法速度奇慢,严重影响到了程序的执行效率
然后我又在网上,发现了map(int, sys.stdin.readline().strip().split())的方式,效率确实也提高了不少,但是请问还有没得效率更高的办法,map和raw_input的方式速度到底是慢在哪里?

巴扎黑
巴扎黑

reply all (0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!