【问题标题】:Trying to read in arrays from multiple .txt files in Python but nothing is appearing尝试从 Python 中的多个 .txt 文件中读取数组,但没有出现任何内容
【发布时间】:2019-05-12 20:53:57
【问题描述】:

我正在尝试将多个 .txt 文件读入我的程序,但是当我运行该程序时,不会打印 precip 变量并且没有错误。

这是我的代码:

import pandas as pd
year = 2014
while year > 2019:  
    day = 1
    while day < 31:
        infile = 'p24i_{0:4.0f}06{1:02.0f}_sortbyvalue.txt'.format(year, day)
        data_in = pd.read_csv(infile, skiprows=6, delim_whitespace=True, header=None).values
        precip = data_in[:,0]
        print(precip)
        day+=1  
    year+=1

【问题讨论】:

    标签: python arrays loops output


    【解决方案1】:

    year2014,所以while year &gt; 2019: 循环中的代码不会运行,因为2014 &gt; 2019False,也许你的意思是:

    while year < 2019:
        # do
    

    【讨论】:

      猜你喜欢
      • 2022-12-18
      • 1970-01-01
      • 2023-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-17
      • 1970-01-01
      • 2016-05-03
      相关资源
      最近更新 更多