我是Pandas和Python的新手.我想在我的脚本中做一些日期时间操作.我从以下格式的csv文件中获取日期时间信息: 01APR2017 6:59
如何将其转换为pandas datetime格式?像: 2017-04-01 06:59:00
在下面的代码中,我试图使用python脚本创建一个"更多"命令(unix),方法是将文件读入列表并一次打印10行,然后询问用户是否要打印下10行(打印更多. ).问题是raw_input一次又一次地要求输入,如果我给'y'或'Y'作为输入并且不继续while循环并且如果我给任何其他输入while循环制动.我的代码可能不是最好的学习python.
import sys
import string
lines = open('/Users/abc/testfile.txt').readlines()
chunk = 10
start = 0
while 1:
block = lines[start:chunk]
for i in block:
print i
if raw_input('Print More..') not in ['y', 'Y']:
break
start = start + chunk
Run Code Online (Sandbox Code Playgroud)
我得到的输出代码是: -
--
10 lines from file
Print More..y
Print More..y
Print More..y
Print More..a
Run Code Online (Sandbox Code Playgroud)