A.1-1 CSDN上怎么粘贴有格式的代码
step1:在弹出的窗口上面“编程语言”下拉列表中,选择语言类型(本例选Python)。
step2: 在弹出的窗口输入或粘贴上面的代码。并确定。结果如下。(编辑的时候看不到行号,审核之后就有了)
import math
import os
from os import path
import numpy as np
filePath = input("Please enter the file path: ");
while not path.exists(filePath):
filePath = input("File path error, please re-enter: ");
if path.exists(filePath):
break
file_object = open(filePath,"r").readlines()
rainfall=[]
for line in file_object()[5:]:
for i in range:
if file_object(i)>0.1:
rainfall.append(file_object(i))
b=np.sum(rainfall)
print (b)