# _*_coding:utf-8_*_import os
import pandas as pd
import pymysql# Press the green button in the gutter to run the script.if __name__ =='__main__':strFilePath1 = os.getcwd()+"/天气.csv"df1 = pd.read_csv(strFilePath1)print(df1)strFilePath2 = os.getcwd()+"/天气.txt"df2 = pd.read_csv(strFilePath2, sep='\t', header=None, names=["时间","天气状况","气温","风力风向"])print(df2)strFilePath3 = os.getcwd()+"/天气.xlsx"df3 = pd.read_excel(strFilePath3)print(df3)conn = pymysql.connect(host='127.0.0.1', user='root', password='root', database='test', charset='utf8')df4 = pd.read_sql("select * from mytable", con=conn)print(df4)
python函数示例Python input()函数 (Python input() function) input() function is a library function, it is used to get the user input, it shows given message on the console and wait for the input and returns input value in string format. input()函数是一个库函…
# _*_coding:utf-8_*_
import pandas as pd# 自定义函数
def func(df):return df[temperature] < 32# Press the green button in the gutter to run the script.
if __name__ __main__:data {date: [2022-08-21, 2022-08-22, 2022-08-23],weather: ["晴", &quo…
下面代码在Linux下运行
# _*_coding:utf-8_*_
import os
import pandas as pd# 自定义函数
def func(x):if x[temperature] > 30:return 高温if x[temperature] < 10:return 低温return 常温# Press the green button in the gutter to run the script.
if __name__ __…
python函数示例Python float()函数 (Python float() function) float() function is a library function in Python, it is used to get a float value from a given number or a string. It accepts either a string (that should contain a number) or a number and returns …
python中assertPython断言关键字 (Python assert keyword) assert is a keyword (case-sensitive) in python, it is used to debug the code. Generally, it can be used to test a condition – if a condition returns False – it returns an Assertion Error (AssertionEr…
python中list函数Python list()函数 (Python list() function) list() function is a library function, it is used to create a list, it accepts multiple elements enclosed within brackets (because list() takes only one argument. Thus, the set of elements within b…
python 示例Python类关键字 (Python class keyword) class is a keyword (case-sensitive) in python, it is used to define a class, when we need to define a class, before the class name - we must have to use class keyword. class是python中的一个关键字(区分大小写)…