330day(Xcode9使用python3)

博客主要讲述在Mac上使用Xcode9搭配Python3时遇到的问题及解决办法。因Mac自带Python导致使用混乱,需注意路径。还涉及安装xcode command line tool、homebrew,给系统Python安装pip等操作,过程中遇到问题均通过参考相关链接解决。

《2018年8月29日》【连续330天】

标题:Xcode9使用python3;

内容:
Mac上自带了python,导致使用的时候出现了混乱,使用 xcode的时候要注意路径:

 参考:https://blog.youkuaiyun.com/u010828718/article/details/70257622

在终端上找了一下位置,已安装Xcode:

接着安装xcode command line tool:

在终端输入xode-select --install;

安装homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装完后检查:brew doctor

结果显示 not found..

 查了一下:发现只要在添加一条路径即可:PATH=".;$PATH:/usr/local/bin"

 修改变量参考:https://www.cnblogs.com/malcolmfeng/p/6902569.html

不过添加的时候,复制了别人的文本,里面居然有中文字符,。。终端处理命令都不能用了

参考:https://blog.youkuaiyun.com/a10241234/article/details/45173309

解决了;

easy_install pip :给系统的python安装pip

又失败了。。

解决参考:https://blog.youkuaiyun.com/u013957017/article/details/80818815

 

xcode 使用python3:https://blog.youkuaiyun.com/f_zyj/article/details/80426373

将python3的path填上即可;

import time import re from DrissionPage import SessionPage import pandas as pd import numpy as np from datetime import datetime def get_predict_weather(url): predict_list = [] page = SessionPage() page.get(url) ele = page('#dayList') for child in ele.children()[:14]: temp = [] messages = child.eles('.day-item') # 使用 eles 方法获取子元素 #one_day_message = ele.page(child) #messages = one_day_message.eles('.day-item') for message in messages: temp.append(message.text) high_temperature = child.ele('.high').text # 使用 ele 方法获取单个子元素 #high_temperature = child.page('.high').text temp.append(high_temperature) low_temperature = child.ele('.low').text #low_temperature = child.page('.low').text temp.append(low_temperature) predict_list.append(temp) return predict_list def turn_to_df(predict_list): df = pd.DataFrame(columns=['星期', '日期', '白天天气', '白天风向', '白天风力', '夜间天气', '夜晚风向', '夜间风力', '最高气温','最低气温']) for i in predict_list: time.sleep(np.random.normal(10, 1));temp_list = [] for j in range(len(i)): if j == 0 : parts = i[0].split('\n') temp_list.append(parts[0]) temp_list.append(parts[1]) else: temp_list.append(i[j]) new_row_df = pd.DataFrame([temp_list], columns= df.columns) df = pd.concat([df, new_row_df], ignore_index=True) return df 将以上代码改为苹果系统可用
最新发布
03-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值