java 删除txt,如何从.txt文件中删除2个值
if "A" in columns and int(columns[5]) < int(columns[3]):
print(columns)
print (columns[3]) - (columns[5])
我在這做錯(cuò)了什么?不記得我最近開(kāi)始編碼 .
這是完整的代碼:
import csv
FILE_NAME = "paintingJobs.txt" #I use this so that the file can be used easier
COL_HEADERS = ['Number', 'Date', 'ID', 'Total', 'Status', 'Paid']
NUM_COLS = len(COL_HEADERS)#This will insure that the header of each column fits into the length of the data
# read file once to determine maximum width of data in columns
with open(FILE_NAME) as f:
reader = csv.reader(f, delimiter=',')
# determine the maximum width of the data in each column
max_col_widths = [len(col_header) for col_header in COL_HEADERS]
for columns in reader:
for i, col in enumerate(columns):
if "A" in columns and int(columns[5]) < int(columns[3]):
max_col_widths[i] = max(max_col_widths[i], len(repr(col)))
# add 1 to each for commas
max_col_widths = [col_width+1 for col_width in max_col_widths]
# read file second time to display its contents with the headers
with open(FILE_NAME) as f:
reader = csv.reader(f, delimiter=',')
# display justified column headers
print(' ' + ' '.join(col_header.ljust(max_col_widths[i])
for i, col_header in enumerate(COL_HEADERS)))
# display justified column data
for columns in reader:
if "A" in columns and int(columns[5]) < int(columns[3]):
print(columns)
print (columns[3]) - (columns[5])`
這是我得到的錯(cuò)誤:
line 72, in Option_B
print (columns[3]) - (columns[5])
TypeError:不支持的操作數(shù)類型 - :'NoneType'和'str'
總結(jié)
以上是生活随笔為你收集整理的java 删除txt,如何从.txt文件中删除2个值的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python3经典实例_Python3十
- 下一篇: lammps软件_Lammps模型构建的