  In the past few years, linear codes with few weights and their weight
analysis have been widely studied. In this paper, we further investigate a
class of two-weight or three-weight linear codes from defining sets and
determine their weight and complete weight enumerators by application of the
theory of quadratic forms and some special Weil sums over finite fields. Some
punctured codes of the discussed linear codes are optimal or almost optimal
with respect to the Griesmer bound. This paper generalizes some results in
\cite{ZhuXu2017,Jian2019}.
