我有一个我用多行创建的.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) 我试图弄清楚如何在案例陈述中测试两个条件.
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工作,我做错了什么?
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)