私はPythonに少し慣れていないので、このスクリプトを作成して1 mbを超える印刷ジョブをキャンセルしようとしています..(サイズをチェックしている行は、機能していることを確認するために1 mbに設定されています)。何らかの理由で、私の最後のelseステートメントには無効な構文があると言い続けています。すべての括弧が閉じているかどうかを確認しましたが、一致しないペアは見つかりませんでした。誰かがそれが無効であると言う理由を教えてもらえますか? また、24 行目 (fullname = ...grep...) を見て、構文が正しいことを確認できますか?
#! /usr/bin/python
import os
infile = open ('test.pl', 'r')
outfile = open('print.reportpython', 'w+')
newfile = infile.readlines()
newfile.pop(0)
count = 0
firstline = newfile[0]
splitline = firstline.split()
currentuser = splitline[1]
currentuser = str(currentuser)
for line in newfile:
newline = line.split()
names = newline[1]
size = int(newline[2])
names = str(names)
print names
if names is currentuser:
if size >= 1:
os.popen ("cancel lab01-10292")
fullname = os.popen("cat /etc/passwd |grep " + newline[1] + "cut -d':' -f5")
count += 1
print count
else:
print outfile.write ("(" + currentuser + ")")
print outfile.write (" ")
count = 0
currentuser = names