Because you have already read the file and there is nothing left to read.
Try this instead:
import streamlit as st
import pandas as pd
def read_data(filename):
df = pd.read_csv(filename, encoding='gbk')
return df
file = st.file_uploader("upload:")
if file:
st.subheader("1")
df1 = pd.read_csv(file, encoding="gbk")
st.write(df1)
st.subheader("2")
file.seek(0) # Back to the beginning of the file.
df = read_data(file) # st.write(pd.read_csv(file, encoding="gbk"))
st.write(df)