6. Given the set $A=\{1,2, \cdots, 2019\}$, the mapping $f: A \rightarrow A$ satisfies that for any $k \in A$, $f(k) \leqslant k$, and the image has exactly 2018 different values. Then the number of mappings $f$ that satisfy the condition is $\qquad$.
6. $2^{2019}-2020$.

Let $n \in A$, and at the same time, $n$ is not in the range of $f$; $m \in A$, and there exist two different pre-images, both of whose images are $m$.

From the conditions, $f(1)=1$, and for any $x \leqslant m$, $f(x)=x$.

If $n > m$, $f(x) = x$. Therefore, for the mapping $f$, it must be that $m < n$.

Next, determine the number of ways to assign values to $f(x)$ when $m+1 \leqslant x < n$.

Since $f(m+1)=m$ or $f(m+1)=m+1$, when $m < k < n$, assuming $f(1), f(2), \cdots, f(k-1)$ are already determined, $f(k)$ has two different values to choose from, one of which is $k$ and the other is the number among $1,2, \cdots, m-1$, $m, m, m+1, \cdots, k-1$ that has not been used (where $m$ is used twice).

Thus, for $x \in [m, n)$, $f(x)$ has two different ways to be assigned, and $f(n)$ has only one different value. Therefore, for a given $m < n$, the number of $f$ that satisfy the requirements is $2^{n-m-1}$. Hence, the number of $f$ is
$$
\begin{array}{l}
\sum_{m=1}^{2018} \sum_{n=m+1}^{2019} 2^{n-m-1}=\sum_{m=1}^{2018} 2^{-m-1} \sum_{n=m+1}^{2019} 2^{n} \\
=\sum_{m=1}^{2018} 2^{-m-1}\left(2^{2020}-2^{m+1}\right)=2^{2019}-2020 .
\end{array}
$$