写Excel操作
import pandas as pd
players = [{'dailyWinners': 3, 'dailyFreePlayed': 2, 'user': 'Player1', 'bank': 0.06},
{'dailyWinners': 3, 'dailyFreePlayed': 2, 'user': 'Player2', 'bank': 4.0},
{'dailyWinners': 1, 'dailyFree': 2, 'user': 'Player3', 'bank': 3.1},
{'dailyWinners': 3, 'dailyFree': 2, 'user': 'Player4', 'bank': 0.32}]
df = pd.DataFrame.from_dict(players)
print (df)
df.to_excel('players.xlsx')
读Excel操作
import pandas as pd
df = pd.read_excel('players.xlsx', index_col=0)
print('Excel Data to Dict:', df.to_dict(orient='record'))
print('----------------------------------------------------------------------')
print('Excel Data to JSON:', df.to_json(orient='records'))
print('-----------------------------------------------------------------------')
print('Excel Data to CSV:\n', df.to_csv(index=False))