小编Sou*_*ena的帖子

将字符串日期时间转换为pandas datetime

我是Pandas和Python的新手.我想在我的脚本中做一些日期时间操作.我从以下格式的csv文件中获取日期时间信息: 01APR2017 6:59

如何将其转换为pandas datetime格式?像: 2017-04-01 06:59:00

python csv datetime python-2.7 pandas

6
推荐指数
1
解决办法
1万
查看次数

为什么while循环粘在raw_input上?(蟒蛇)

在下面的代码中,我试图使用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)

python raw-input while-loop

3
推荐指数
1
解决办法
932
查看次数

标签 统计

python ×2

csv ×1

datetime ×1

pandas ×1

python-2.7 ×1

raw-input ×1

while-loop ×1