2019年11月5日

摘要: # -*- coding: utf-8 -*- 1. 查找单个电话号码 from phone import Phone def get_phone_info(phone_num): phone_info = Phone().find(phone_num) try: phone = phone_inf 阅读全文
posted @ 2019-11-05 23:15 落日峡谷 阅读(1801) 评论(0) 推荐(0) 编辑

2019年11月2日

摘要: 1. '%'字符串格式化 #方法一: '%' num = 10 print('--the number is %d--'%num) #output: "--the number is 10--" print('the float number is %f'%-3.14) #output: "the 阅读全文
posted @ 2019-11-02 21:41 落日峡谷 阅读(762) 评论(0) 推荐(0) 编辑
摘要: 1. 分片的步长,默认为值1,表示为 xx[s:t:v] 从索引s到索引t,每隔v,取对应索引位置的值 xx = 'hello,world' #从索引0-10,共11个字符 xx[2:] #从索引2直到最后所有的值 Out[2]: 'llo,world' xx[1:5:2] #从索引1到5,即xx[ 阅读全文
posted @ 2019-11-02 16:52 落日峡谷 阅读(600) 评论(0) 推荐(0) 编辑

2019年10月31日

摘要: 使用hive时,建立数据库,建表,写数据; 读数据:select * from test_t2; 报错SemanticException 原因:建表时使用了其他路径,或者在另一个路径的数据库(建立数据库时指定了location参数:create database words_db location 阅读全文
posted @ 2019-10-31 16:42 落日峡谷 阅读(2021) 评论(0) 推荐(0) 编辑
摘要: #_*_coding:utf-8_*_ # spark读取csv文件 #指定schema: schema = StructType([ # true代表不为null StructField("column_1", StringType(), True), # nullable=True, this 阅读全文
posted @ 2019-10-31 15:30 落日峡谷 阅读(12179) 评论(2) 推荐(1) 编辑
摘要: 1. schema参数,AssertionError: dataType should be DataType # AssertionError: dataType should be DataType schema = StructType([ # true代表不为空 StructField("c 阅读全文
posted @ 2019-10-31 11:46 落日峡谷 阅读(1932) 评论(0) 推荐(0) 编辑

2019年10月30日

摘要: 1. pyspark读csv文件后无法显示中文 #pyspark读取csv格式时,不能显示中文 df = spark.read.csv(r"hdfs://mymaster:8020/user/root/data_spark.csv", schema=schema) #解决方法,加入encoding= 阅读全文
posted @ 2019-10-30 21:37 落日峡谷 阅读(2097) 评论(0) 推荐(0) 编辑
摘要: Mysql错误 [Err] 1630 1. 错误 1630 [SQL]select date_format(now (),'%Y%m%d'); [Err] 1630 - FUNCTION db.now does not exist. Check the 'Function Name Parsing 阅读全文
posted @ 2019-10-30 10:43 落日峡谷 阅读(1662) 评论(0) 推荐(0) 编辑

2019年10月28日

摘要: Python使用中可能遇到的小问题 AttributeError: 'NoneType' object has no attribute 'extend' 或者AttributeError: 'NoneType' object has no attribute 'append' 原因:这两种方法都是 阅读全文
posted @ 2019-10-28 16:34 落日峡谷 阅读(14319) 评论(0) 推荐(1) 编辑

2019年10月23日

摘要: 官网:https://packaging.python.org/tutorials/installing-packages/ 首先查看已安装的包: 1. 命令行模式输入:pydoc modules 2. python解释器输入:help("modules") ## 目前常用的是pip和easy_in 阅读全文
posted @ 2019-10-23 21:47 落日峡谷 阅读(2151) 评论(0) 推荐(0) 编辑

导航