小编All*_*ady的帖子

Python 3.2 - readline()正在跳过源文件中的行

我有一个我用多行创建的.txt文件.

当我使用计数累加器运行for循环时,它会跳过行.

它跳过顶线,从第二个开始,打印第四个,第六个等...

我错过了什么?

** for your reading pleasure**
def main():
    # Open file line_numbers.txt
    data_file = open('line_numbers.txt', 'r')

    # initialize accumulatior
    count = 1


    # Read all lines in data_file
    for line in data_file:
        # Get the data from the file
        line = data_file.readline()

        # Display data retrieved
        print(count, ": ", line)

        # add to count sequence
        count += 1
Run Code Online (Sandbox Code Playgroud)

python readline accumulator

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

VB 2010中使用Select Case的多个条件

我试图弄清楚如何在案例陈述中测试两个条件.

Select Case txtWeight.Text
     Case Is <= 2
        decShippingCost = (decShipping2 + (decShipping2 * 0.26))
     Case Is > 2 and <= 4
        decShippingCost = (decShipping4 + (decShipping4 * 0.026))
Run Code Online (Sandbox Code Playgroud)

我无法让AND工作,我做错了什么?

vb.net case

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

继续获取未定义的全局名称错误

def defineType(riskCode):
    if riskCode == 1:
        riskType = High
    else:
        if riskCode == 2:
            riskType = Moderate
        else:
            if riskCode == 3:
                riskType = Low
            else:
                if RiskCode == 4:
                    riskType = No
Run Code Online (Sandbox Code Playgroud)

这是我正在为一个班级工作的计划的一部分......

# Global Variables
custName = input('Please enter your name: ')
custAge = int(input('Please enter your age: '))
custViolation = int(input('Please enter the number of violations: '))

riskCode = 0
estimatePrice = 0
riskType = none
Run Code Online (Sandbox Code Playgroud)

这些是我的全局变量......

Traceback (most recent call last):
  File "C:\Users\Alli\Downloads\HwyRobbery.py", line 13, in …
Run Code Online (Sandbox Code Playgroud)

python variables global

1
推荐指数
2
解决办法
8204
查看次数

标签 统计

python ×2

accumulator ×1

case ×1

global ×1

readline ×1

variables ×1

vb.net ×1